[Python-checkins] cpython: Closes issue #14163 - tkinter: problems with hello doc example

andrew.svetlov python-checkins at python.org
Thu Mar 15 05:41:36 CET 2012


http://hg.python.org/cpython/rev/d8ba959a547b
changeset:   75688:d8ba959a547b
user:        Andrew Svetlov <andrew.svetlov at gmail.com>
date:        Wed Mar 14 21:41:23 2012 -0700
summary:
  Closes issue #14163 - tkinter: problems with hello doc example

files:
  Doc/library/tkinter.rst |  43 ++++++++++++----------------
  1 files changed, 19 insertions(+), 24 deletions(-)


diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst
--- a/Doc/library/tkinter.rst
+++ b/Doc/library/tkinter.rst
@@ -179,35 +179,30 @@
 
 ::
 
-   from tkinter import *
+    import tkinter as tk
 
-   class Application(Frame):
-       def say_hi(self):
-           print("hi there, everyone!")
+    class Application(tk.Frame):
+        def __init__(self, master=None):
+            tk.Frame.__init__(self, master)
+            self.pack()
+            self.createWidgets()
 
-       def createWidgets(self):
-           self.QUIT = Button(self)
-           self.QUIT["text"] = "QUIT"
-           self.QUIT["fg"] = "red"
-           self.QUIT["command"] = self.quit
+        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.pack({"side": "left"})
+            self.QUIT = tk.Button(self, text = "QUIT", fg = "red",
+                                                command = root.destroy)
+            self.QUIT.pack(side = "bottom")
 
-           self.hi_there = Button(self)
-           self.hi_there["text"] = "Hello",
-           self.hi_there["command"] = self.say_hi
+        def say_hi(self):
+            print("hi there, everyone!")
 
-           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()
+    root = tk.Tk()
+    app = Application(master=root)
+    app.mainloop()
 
 
 A (Very) Quick Look at Tcl/Tk

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list