Kaydet (Commit) a80af770 authored tarafından Daniel Lovell's avatar Daniel Lovell Kaydeden (comit) Serhiy Storchaka

bpo-35086: Fix tkinter example "A Simple Hello World Program". (GH-10160)

The root widget was accessed as a global variable in the Application's method.
üst 31368a4f
...@@ -205,6 +205,7 @@ A Simple Hello World Program ...@@ -205,6 +205,7 @@ A Simple Hello World Program
class Application(tk.Frame): class Application(tk.Frame):
def __init__(self, master=None): def __init__(self, master=None):
super().__init__(master) super().__init__(master)
self.master = master
self.pack() self.pack()
self.create_widgets() self.create_widgets()
...@@ -215,7 +216,7 @@ A Simple Hello World Program ...@@ -215,7 +216,7 @@ A Simple Hello World Program
self.hi_there.pack(side="top") self.hi_there.pack(side="top")
self.quit = tk.Button(self, text="QUIT", fg="red", self.quit = tk.Button(self, text="QUIT", fg="red",
command=root.destroy) command=self.master.destroy)
self.quit.pack(side="bottom") self.quit.pack(side="bottom")
def say_hi(self): def say_hi(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment