@@ -199,19 +199,19 @@ A Simple Hello World Program
199199
200200 class Application(tk.Frame):
201201 def __init__(self, master=None):
202- tk.Frame. __init__(self, master)
202+ super(). __init__(master)
203203 self.pack()
204- self.createWidgets ()
204+ self.create_widgets ()
205205
206- def createWidgets (self):
206+ def create_widgets (self):
207207 self.hi_there = tk.Button(self)
208208 self.hi_there["text"] = "Hello World\n(click me)"
209209 self.hi_there["command"] = self.say_hi
210210 self.hi_there.pack(side="top")
211211
212- self.QUIT = tk.Button(self, text="QUIT", fg="red",
212+ self.quit = tk.Button(self, text="QUIT", fg="red",
213213 command=root.destroy)
214- self.QUIT .pack(side="bottom")
214+ self.quit .pack(side="bottom")
215215
216216 def say_hi(self):
217217 print("hi there, everyone!")
@@ -536,7 +536,7 @@ For example::
536536
537537 class App(Frame):
538538 def __init__(self, master=None):
539- Frame .__init__(self, master)
539+ super() .__init__(master)
540540 self.pack()
541541
542542 self.entrythingy = Entry()
@@ -581,13 +581,13 @@ part of the implementation, and not an interface to Tk functionality.
581581
582582Here are some examples of typical usage::
583583
584- from tkinter import *
585- class App(Frame):
584+ import tkinter as tk
585+
586+ class App(tk.Frame):
586587 def __init__(self, master=None):
587- Frame .__init__(self, master)
588+ super() .__init__(master)
588589 self.pack()
589590
590-
591591 # create the application
592592 myapp = App()
593593
@@ -708,13 +708,13 @@ add
708708
709709For example::
710710
711- def turnRed (self, event):
711+ def turn_red (self, event):
712712 event.widget["activeforeground"] = "red"
713713
714- self.button.bind("<Enter>", self.turnRed )
714+ self.button.bind("<Enter>", self.turn_red )
715715
716716Notice how the widget field of the event is being accessed in the
717- :meth: ` turnRed ` callback. This field contains the widget that caught the X
717+ `` turn_red() ` ` callback. This field contains the widget that caught the X
718718event. The following table lists the other event fields you can access, and how
719719they are denoted in Tk, which can be useful when referring to the Tk man pages.
720720
0 commit comments