BuroBernd
BuroBernd

Reputation: 454

Python: Set Color for Tkinter Button using .grid()

using the Python 2.7 Tkinter Grid Layouter, i would like to do something like

root.button = Button(root, bg = 'green', ....)
root.button.grid(...)

in order to get a green button. Running this, it doesn't bring up any errors, but the button does not take the desired color. Any suggestions greatly appreciated!

EDIT: thanks for the code, i copied it and run it, here is what i get: still a white button ..? enter image description here

Upvotes: 0

Views: 7861

Answers (1)

falsetru
falsetru

Reputation: 369274

Passing bg keyword argument works as expected. Try following:

from Tkinter import *
root = Tk()
button = Button(root, text='buggton', bg='green')
button.grid(row=0, column=0)
root.mainloop()

enter image description here

Upvotes: 1

Related Questions