]> granicus.if.org Git - python/commitdiff
Patch #911176: Move test function into __main__
authorMartin v. Löwis <martin@v.loewis.de>
Mon, 22 Mar 2004 21:49:47 +0000 (21:49 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Mon, 22 Mar 2004 21:49:47 +0000 (21:49 +0000)
Lib/lib-tk/SimpleDialog.py

index bbd6b9f809156d481f3f7e81a3c4d30f0e36fc7e..bb63a8df01e05915b0ea72c9376aa1ec932226a5 100644 (file)
@@ -86,10 +86,12 @@ class SimpleDialog:
         self.root.quit()
 
 
-def test():
-    root = Tk()
-    def doit(root=root):
-        d = SimpleDialog(root,
+if __name__ == '__main__':
+
+    def test():
+        root = Tk()
+        def doit(root=root):
+            d = SimpleDialog(root,
                          text="This is a test dialog.  "
                               "Would this have been an actual dialog, "
                               "the buttons below would have been glowing "
@@ -99,13 +101,11 @@ def test():
                          default=0,
                          cancel=2,
                          title="Test Dialog")
-        print d.go()
-    t = Button(root, text='Test', command=doit)
-    t.pack()
-    q = Button(root, text='Quit', command=t.quit)
-    q.pack()
-    t.mainloop()
+            print d.go()
+        t = Button(root, text='Test', command=doit)
+        t.pack()
+        q = Button(root, text='Quit', command=t.quit)
+        q.pack()
+        t.mainloop()
 
-
-if __name__ == '__main__':
     test()