Button Hintergrundfarbe
Verfasst: Freitag 17. Februar 2012, 17:47
Hallo erstmal!
Habe ein kleines Problem! Also: Will die Farbe von Buttons in einer Unterfunktion ändern, aber irgendwie funktioniert das nicht! Zwei kurze Programme dazu:
Da gehts:
da nicht:
ABER WARUM??
BITTE HILFE!!!!
Danke!
Habe ein kleines Problem! Also: Will die Farbe von Buttons in einer Unterfunktion ändern, aber irgendwie funktioniert das nicht! Zwei kurze Programme dazu:
Da gehts:
Code: Alles auswählen
from Tkinter import *
from tkColorChooser import *
def setBgColor( ):
push.config(bg='blue')
push2.config(bg='yellow')
def setBgColor2():
push.config(bg='red')
push2.config(bg='grey')
root = Tk( )
push = Button(root, text='Set Background Color', command=setBgColor)
push.pack()
push2 = Button(root, text='Set Background Color2', command= setBgColor2)
push2.pack()
root.mainloop()
Code: Alles auswählen
from Tkinter import *
from tkColorChooser import *
def setBgColor( ):
push.config(bg='blue')
push2.config(bg='yellow')
def setBgColor2():
push.config(bg='red')
push2.config(bg='grey')
def bla():
root = Tk( )
push = Button(root, text='Set Background Color', command=setBgColor)
push.pack()
push2 = Button(root, text='Set Background Color2', command= setBgColor2)
push2.pack()
root.mainloop()
main=Tk()
main=Button(None, text='BgChange', command=bla)
main.pack()
main.mainloop()
BITTE HILFE!!!!
Danke!