Forum Archive

Button Background Colour

GaryGadget

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

@GaryGadget

        button_name.background_color = 'lightgray'
GaryGadget

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?

omz

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

cvp

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

GaryGadget

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

ellie_ff1493

@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