在下面的代碼中,app是mainWindow的一個實例,它從Tkinter.Frame繼承。我試圖使用Frame.Configure方法來更改Frame的背景顏色。但是,調用self.configure(background =「yellow」)不起作用。有人能幫助我理解我正在犯的錯誤嗎?創建後無法更改框架顏色
import Tkinter
class mainWindow(Tkinter.Frame):
def __init__(self, parent):
Tkinter.Frame.__init__(self, master=parent)
self.parent=parent
self.button1=Tkinter.Button(master=self.parent, text='ONE', command=self.change)
self.button1.pack()
self.pack()
def change(self):
self.parent.wm_title("Changed")
self.configure(background="yellow")
root = Tkinter.Tk()
root.geometry("600x600+50+50")
app=mainWindow(root)
root.mainloop()