Skip to content

Commit a3837a0

Browse files
committed
Patch #911176: Move test function into __main__
1 parent 211a2eb commit a3837a0

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

Lib/lib-tk/SimpleDialog.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ def done(self, num):
8686
self.root.quit()
8787

8888

89-
def test():
90-
root = Tk()
91-
def doit(root=root):
92-
d = SimpleDialog(root,
89+
if __name__ == '__main__':
90+
91+
def test():
92+
root = Tk()
93+
def doit(root=root):
94+
d = SimpleDialog(root,
9395
text="This is a test dialog. "
9496
"Would this have been an actual dialog, "
9597
"the buttons below would have been glowing "
@@ -99,13 +101,11 @@ def doit(root=root):
99101
default=0,
100102
cancel=2,
101103
title="Test Dialog")
102-
print d.go()
103-
t = Button(root, text='Test', command=doit)
104-
t.pack()
105-
q = Button(root, text='Quit', command=t.quit)
106-
q.pack()
107-
t.mainloop()
104+
print d.go()
105+
t = Button(root, text='Test', command=doit)
106+
t.pack()
107+
q = Button(root, text='Quit', command=t.quit)
108+
q.pack()
109+
t.mainloop()
108110

109-
110-
if __name__ == '__main__':
111111
test()

0 commit comments

Comments
 (0)