diff options
Diffstat (limited to 'python/helpers/pydev/tests_mainloop/gui-tk.py')
-rw-r--r-- | python/helpers/pydev/tests_mainloop/gui-tk.py | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/python/helpers/pydev/tests_mainloop/gui-tk.py b/python/helpers/pydev/tests_mainloop/gui-tk.py index 69ceb0b9f053..4cef45f91a4a 100644 --- a/python/helpers/pydev/tests_mainloop/gui-tk.py +++ b/python/helpers/pydev/tests_mainloop/gui-tk.py @@ -8,24 +8,26 @@ To run this: interactive console """ -try: - from Tkinter import * -except: - # Python 3 - from tkinter import * - -class MyApp: - - def __init__(self, root): - frame = Frame(root) - frame.pack() - - self.button = Button(frame, text="Hello", command=self.hello_world) - self.button.pack(side=LEFT) - - def hello_world(self): - print("Hello World!") - -root = Tk() - -app = MyApp(root) +if __name__ == '__main__': + + try: + from Tkinter import * + except: + # Python 3 + from tkinter import * + + class MyApp: + + def __init__(self, root): + frame = Frame(root) + frame.pack() + + self.button = Button(frame, text="Hello", command=self.hello_world) + self.button.pack(side=LEFT) + + def hello_world(self): + print("Hello World!") + + root = Tk() + + app = MyApp(root) |