File: gui-tk.py

package info (click to toggle)
pydevd 3.4.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,892 kB
  • sloc: python: 77,580; cpp: 1,873; sh: 374; makefile: 50; ansic: 4
file content (31 lines) | stat: -rw-r--r-- 732 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
"""Simple Tk example to manually test event loop integration.

To run this:
1) Enable the PyDev GUI event loop integration for tk
2) do an execfile on this script
3) ensure you have a working GUI simultaneously with an
   interactive console
"""

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)