omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Display an image in the free area of a form_dialog

    Pythonista
    1
    3
    1605
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • cvp
      cvp last edited by

      I've a form_dialog with only 4 lines(fields).
      Thus the free area is big enough to display an image.
      How do I could define a PIL image in this free area?
      Of course, I could copy the dialogs.py module in a folder where I could modify it with my own container_view and add an image as sub_view.
      Thanks for your very appreciate permanent help.

      1 Reply Last reply Reply Quote 0
      • cvp
        cvp last edited by

        So I did it.
        With only a short myform_dialog (simple, without sections) with a new parameter for the image to display.

        def myform_dialog(title='', fields=None,sections=None, done_button_title='Done',cover=None):
        
        	sections = [('', fields)]
        	c = dialogs._FormDialogController(title, sections, done_button_title=done_button_title)
        	y = 35
        	for s in c.cells:
        		for cell in s:
        			y = y + cell.height
        	if cover != None:
        		w = c.container_view.width
        		h = c.container_view.height - y
        		x = 0
        		cover_image = ui.ImageView(frame=(x,y,w,h))
        		cover_image.content_mode = ui.CONTENT_SCALE_ASPECT_FIT
        		cover_image.image = ui.Image.from_data(cover)
        		c.container_view.add_subview(cover_image)	
        		
        	c.container_view.present('sheet')
        	c.container_view.wait_modal()
        	# Get rid of the view to avoid a retain cycle:
        	c.container_view = None
        	if c.was_canceled:
        		return None
        	return c.values
        

        example

        1 Reply Last reply Reply Quote 0
        • cvp
          cvp last edited by cvp

          @Webmaster4o , I used your code for the embedded picture, thanks

          1 Reply Last reply Reply Quote 1
          • First post
            Last post
          Powered by NodeBB Forums | Contributors