0

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

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
BuroBernd
  • 444
  • 3
  • 8
  • 20

1 Answers1

1

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

falsetru
  • 357,413
  • 63
  • 732
  • 636
  • @BuroBernd, Ahh, you use osx. See [How do I change the foreground or background colour of a Tkinter button on Max OS X 10.6 with Python 2.6.1?](http://stackoverflow.com/questions/1529847/how-do-i-change-the-foreground-or-background-colour-of-a-tkinter-button-on-max-o) – falsetru Sep 15 '13 at 12:02