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.


    Button Background Colour

    Pythonista
    4
    7
    4713
    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.
    • GaryGadget
      GaryGadget last edited by

      Hi,
      Quick one I hope.

      Is it possible to change the background colour of a button from within code, i.e. I want to make the colour dynamic so I can make it all black or white like a crossword. Or should I utilise the image to match my needs?

      Thanks for your time.

      Regards
      Gary

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

        @GaryGadget

        		button_name.background_color = 'lightgray'
        
        1 Reply Last reply Reply Quote 0
        • GaryGadget
          GaryGadget last edited by

          Thanks for that, I did search the class library for something like this but couldn’t/can’t find it. Am I looking in the wring place?

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

            @GaryGadget Note that ui.Button is a subclass of ui.View, so the background_color property is inherited from that.

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

              @GaryGadget
              Note that when begin to type, the marvelous automatic generation of available methods:

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

                Don’t know how I missed that. Thanks for your help.

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

                  @omzI have a suggestion that in the documentation when something is a subclass it always says so and links to the parent. eg at here

                  "class ui.Button"

                  becomes

                  "class ui.Button (subclass of ui.View)"

                  I have often forgotten something is a subclass or not known

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