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.


    Cannot set color for a ui button

    Editorial
    2
    6
    3759
    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.
    • pruppert222
      pruppert222 last edited by

      I am trying to set the color for a right ButtonItem in a view called 'table.' No matter what I set tint_color to, it does not seem to have an effect. I have tried different color names and hex, but the button title always shows in grey. Any idea what I'm doing wrong?

      My example code:

      doneButton = ui.ButtonItem(title='Done', enabled=True, tint_color='red')
      tableRightButtons = [doneButton]
      
      table.right_button_items = tableRightButtons
      
      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by

        I'm sorry, that's a bug. I think it has to do with my last-minute change of the default UI font, it looks like I'm accidentally overriding other appearance options...

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

          No worries. Thought that might be the case.

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

            It seems that the bug only affects ButtonItems that contain text, so if you can use an image instead, it should work as expected:

            import ui
            
            v = ui.View()
            b = ui.ButtonItem(image=ui.Image.named('ionicons-beer-32'), tint_color='orange')
            v.right_button_items = [b]
            v.present('sheet')
            
            1 Reply Last reply Reply Quote 0
            • pruppert222
              pruppert222 last edited by

              Nice, and I applaud your choice of icon! Is there a full listing of the icon names anywhere?

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

                There's a list in the UI editor when you set an image attribute (e.g. of a Button or ImageView). When you do this in code, you have to append the size though ('-24, '-32', or '-256').

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