# guiObject.py from tkinter import * class AWindowDemo: def __init__(self, rootWin): #Create a label and button to put in the root window! self.button = Button(rootWin, text="Click Me!", command= self.doit) self.button.pack() self.ourRoot = rootWin #Save a reference to the rootWin #which will be used by the doit method! def doit(self): print("Button was clicked!") self.button.config(fg="red") #Change the button! l = Label(self.ourRoot, text="You clicked!") l.pack() #Create the main root window, instantiate the object, and run the main loop! rootWin = Tk() app = AWindowDemo( rootWin ) rootWin.mainloop()