I want all of the buttons in my gui to have the same style. Right now I manually write in the attributes I want but it takes up so much space. Also, if I wanted to change the style I would have to go to every single button. Is it possible to have a style i define once and then reference it when making all buttons? Something like the following:
basic_style =
{'background': 'blue',
'foreground':'white',
'font':'Helvetica 8 bold'}
self.btn = tk.Button(text = 'Hello', style = basic_style)
I know its possible to do something like this:
self.btn['text'] = 'Bye'
but that still doesn't help me much.
Yes, it's even easier than you imagine. Just use dictionary unpacking:
Another popular option is to make a subclass with the style you want, and perhaps other features such as tooltips or style dependant on values or anything else.