Reputation: 41
I'm making a simple game using python and Tkinter. All works well, but I can't seem to change the appearance of the only button in the game (a RESET button on the bottom). It should be flat and blue with white text, to match the rest of the layout. This is the code i'm using now:
resetbutton = Button(root, text='RESET', width=15, command=sw.Reset, highlightbackground="blue", relief='flat')
resetbutton.grid(column=5, columnspan=3, row=13, rowspan=1)
... but the button still looks like the default one. Anyone got any ideas why this doesn't work?
Upvotes: 4
Views: 2324
Reputation: 22804
The given answer is correct, however, if you hover the mouse upon the button, this later one will change both the blue and white colors to the default ones.
So to keep the same design when you hover the mouse, you can add these two options for your resetbutton
button:
activebackground="blue"
activeforeground= "white"
Upvotes: 0
Reputation: 1476
You can do like below with fg and bg (you can also assign fonts [if supported]):
Button(root, text='RESET', command=sw.Reset, font='Arial -20 bold', relief='flat', bg='blue', fg='white', width=10, height=2)
Upvotes: 1