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.


    imageView won't appear

    Pythonista
    2
    3
    2183
    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.
    • smath
      smath last edited by

      I'm working on an app using the ui library, and have run into a problem. Given input from the user, I will produce a plot with matplotlib, which I then plan to have appear in an imageView. The problem is that nothing happens when I press the button that's supposed to make the plot appear. Below is my code:

      import ui
      
      view = ui.View()
      view.height = 800
      view.width = 500					
      view.name = 'Plot test'								
      view.background_color = 'white'
      
      def plot_button():
      	img = ui.Image.named('plot.png')
      	im = ui.ImageView()
      	im.center = (view.width * 0.5, view.height*0.5)
      	im.height = 350
      	im.width = 500
      	im.border_width = 2
      	im.flex = 'LRTB'
      	im.image = img
      	view.add_subview(im)
      	
      go = ui.Button(title = 'Plot')
      go.action = plot_button
      go.width = 100
      go.border_width = 1
      go.border_color = 'grey'
      go.center = (view.width/8, 20)
      go.flex = 'LRTB'
      view.add_subview(go)
      
      view.present('fullscreen')	
      
      1 Reply Last reply Reply Quote 0
      • robinsiebler112
        robinsiebler112 last edited by

        It should be

        def plot_button(sender):
        
        1 Reply Last reply Reply Quote 0
        • smath
          smath last edited by

          Perfect. Thanks.

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