Rob at Dot Net North

I’m back on the road again. Dot Net North have kindly invited me to be the speaker at their first in-person event since the pandemic kicked off. Really looking forward to the event. I’m going to be talking about making music with hardware. There will be devices you can build, devices you can marvel at and hopefully devices that work in front of an audience.

The event is in Manchester on the evening of Tuesday 20th September. You can sign up here.

Tkinter tip: putting buttons back to their original colours

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.