G+_Rud Dog Posted February 16, 2017 Share Posted February 16, 2017 In my attempt to learn tkinter/python3 decided "commenting" examples found on line would help me better understand what the scripts were doing. All was going well when I came across this script. It runs, no problems and understand most of what it is with exceptions. The comments are my interpretation as to what this lines are doing. If you comments explaining what the lines do please do comment. from tkinter import * class App: #No comment only because I have not idea what this next line does. def _init_(self, master): #Multiple frames can be placed in a root window #here we take Frame master placing into "frame" variable. frame = Frame(master) #Place the frame in the root window frame.pack() #Create button with in frame txt=QUIT and FG = red with cmd=quit #If quit button pressed command quit is executed. self.button = Button(frame, text="QUIT", fg="red", command=quit) #Specifically place button on the LEFT. self.button.pack(side=LEFT) #Assign button coinfig parameters and store in variable "self.slogan #Including command when button is pressed which is calling funciton #command "self.write_slogan calling "function write_slogan". self.slogan = Button(frame, text="Hello", command=self.write_slogan) #Place button on the LEFT. frame to use called out above? self.slogan.pack(side=LEFT) def write_slogan(self): print("Tkinter is easy to use!") rootWindow = Tk() app = App(rootWindow) rootWindow.mainloop() Link to comment Share on other sites More sharing options...
Recommended Posts