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.


    Set Button image programmatically

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

      This could be a dumb question. But I had no success on setting a button's image programmatically, i.e. NOT using UI designer.

      I tried following code

      b = ui.Button(image=ui.Image(os.path.expanduser('~/Pythonista.app/Textures/ionicons-close-circled-24.png')))
      

      and

      b = ui.Button()
      b.image = ui.Image(os.path.expanduser('~/Pythonista.app/Textures/ionicons-close-circled-24.png'))
      

      None of above codes works.

      Any advices?

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

        Try:

        b.image = ui.Image.named('ionicons-close-circled-24.png')
        

        See: http://omz-forums.appspot.com/pythonista/post/6449019224064000

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

          Thanks!
          Just realised it is in fact documented ...

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