[Python-checkins] r67239 - sandbox/trunk/tkinter-polo/src/Tkinter.py

guilherme.polo python-checkins at python.org
Sun Nov 16 22:52:33 CET 2008


Author: guilherme.polo
Date: Sun Nov 16 22:52:33 2008
New Revision: 67239

Log:
Removed the example from the module's docstring;
Renamed _test to example;
Removed check for TclVersion >= 8.1 in example since _tkinter requires 8.2 at
    least;
Removed a lambda usage in example that I disliked.


Modified:
   sandbox/trunk/tkinter-polo/src/Tkinter.py

Modified: sandbox/trunk/tkinter-polo/src/Tkinter.py
==============================================================================
--- sandbox/trunk/tkinter-polo/src/Tkinter.py	(original)
+++ sandbox/trunk/tkinter-polo/src/Tkinter.py	Sun Nov 16 22:52:33 2008
@@ -16,18 +16,6 @@
 
 Actions are bound to events by resources (e.g. keyword argument
 command) or with the method bind.
-
-Example (Hello, World):
-import Tkinter
-from Tkconstants import *
-tk = Tkinter.Tk()
-frame = Tkinter.Frame(tk, relief=RIDGE, borderwidth=2)
-frame.pack(fill=BOTH,expand=1)
-label = Tkinter.Label(frame, text="Hello, World")
-label.pack(fill=X, expand=1)
-button = Tkinter.Button(frame,text="Exit",command=tk.destroy)
-button.pack(side=BOTTOM)
-tk.mainloop()
 """
 
 __version__ = "$Revision$"
@@ -3742,32 +3730,34 @@
         self['activebackground'] = self['bg']
 
 ######################################################################
-# Test:
+# Example:
+
+def example():
+
+    def update_btntext():
+        test['text'] = "[%s]" % test['text']
 
-def _test():
     root = Tk()
     text = "This is Tcl/Tk version %s" % TclVersion
-    if TclVersion >= 8.1:
-        try:
-            text = text + unicode("\nThis should be a cedilla: \347",
-                                  "iso-8859-1")
-        except NameError:
-            pass # no unicode support
+    try:
+        text = text + unicode("\nThis should be a cedilla: \347", "iso-8859-1")
+    except NameError:
+        # no unicode support
+        pass
     label = Label(root, text=text)
     label.pack()
-    test = Button(root, text="Click me!",
-              command=lambda root=root: root.test.configure(
-                  text="[%s]" % root.test['text']))
+    test = Button(root, text="Click me!", command=update_btntext)
     test.pack()
-    root.test = test
     quit = Button(root, text="QUIT", command=root.destroy)
     quit.pack()
-    # The following three commands are needed so the window pops
-    # up on top on Windows...
+    # The following three commands are needed so the window pops up
+    # on top on Windows.
+    # XXX I don't have this issue with tk8.4 neither 8.5 on Vista.
     root.iconify()
     root.update()
     root.deiconify()
+
     root.mainloop()
 
 if __name__ == '__main__':
-    _test()
+    example()


More information about the Python-checkins mailing list