Another of those “blog posts that you write so that in six months time, when you hit the same problem you can search for it and find the answer that you wrote for yourself…”
I’m building a little editor for Hull Pixelbot HullOS programs. The editor can deploy code via MQTT or serial terminal so my editor has buttons that let you select which connection you are using. I thought it would be neat to make the buttons change colour to indicate which connection type is in use. Making buttons go green is easy:
button["bg"] = "green"
You can regard a display element as a dictionary (everything in Python is a dictionary) and one of the keys lets you set the background colour.
However, getting a button back to its original colour is a bit more tricky. Word on the street was that the default button background colour is “light grey” but this didn’t work. Perhaps I spelt “grey” wrong. Anyhoo, the correct way to do this is to use the following:
button["bg"] = "SystemButtonFace"
The colour “SystemButtonFace (why am I thinking of boat names?) is the colour that you need.