Hi, I copied this example from a book and have a question. So, in the last line, a object of type class ProcessButtonEvent is created. Now, when it enters the init method, does this obect have any data types? Are the variables window, btOK, and btCancel local variables? I’m a just really confused, isn’t init method only for creating giving attributes to a object. Why can you place “non initializing” code in the init method? Thanks.
from tkinter import *
class ProcessButtonEvent:
def __init__(self):
window = Tk()
btOK = Button(window, text="OK", fg="red", command=self.processOK)
btCancel = Button(window, text="Cancel", fg="blue", command=self.processCancel)
btOK.pack()
btCancel.pack()
window.mainloop()
def processOK(self):
print("OK button was clicked.")
def processCancel(self):
print("Cancel button was clicked.")
ProcessButtonEvent()