]> granicus.if.org Git - python/commitdiff
Closes issue #14163 - tkinter: problems with hello doc example
authorAndrew Svetlov <andrew.svetlov@gmail.com>
Thu, 15 Mar 2012 04:41:23 +0000 (21:41 -0700)
committerAndrew Svetlov <andrew.svetlov@gmail.com>
Thu, 15 Mar 2012 04:41:23 +0000 (21:41 -0700)
Doc/library/tkinter.rst

index ae5635f3c800aa7310cc6e435314e4658a22d3d6..62eedff7d783265cdcf8f707f100885154411ebe 100644 (file)
@@ -179,35 +179,30 @@ A Simple Hello World Program
 
 ::
 
-   from tkinter import *
-
-   class Application(Frame):
-       def say_hi(self):
-           print("hi there, everyone!")
-
-       def createWidgets(self):
-           self.QUIT = Button(self)
-           self.QUIT["text"] = "QUIT"
-           self.QUIT["fg"] = "red"
-           self.QUIT["command"] = self.quit
-
-           self.QUIT.pack({"side": "left"})
-
-           self.hi_there = Button(self)
-           self.hi_there["text"] = "Hello",
-           self.hi_there["command"] = self.say_hi
-
-           self.hi_there.pack({"side": "left"})
-
-       def __init__(self, master=None):
-           Frame.__init__(self, master)
-           self.pack()
-           self.createWidgets()
-
-   root = Tk()
-   app = Application(master=root)
-   app.mainloop()
-   root.destroy()
+    import tkinter as tk
+
+    class Application(tk.Frame):
+        def __init__(self, master=None):
+            tk.Frame.__init__(self, master)
+            self.pack()
+            self.createWidgets()
+
+        def createWidgets(self):
+            self.hi_there = tk.Button(self)
+            self.hi_there["text"] = "Hello World\n(click me)"
+            self.hi_there["command"] = self.say_hi
+            self.hi_there.pack(side="top")
+
+            self.QUIT = tk.Button(self, text = "QUIT", fg = "red",
+                                                command = root.destroy)
+            self.QUIT.pack(side = "bottom")
+
+        def say_hi(self):
+            print("hi there, everyone!")
+
+    root = tk.Tk()
+    app = Application(master=root)
+    app.mainloop()
 
 
 A (Very) Quick Look at Tcl/Tk