Initial import to Tizen
[profile/ivi/python-twisted.git] / doc / core / examples / tkinterdemo.py
1 #!/usr/bin/env python
2
3 # Copyright (c) Twisted Matrix Laboratories.
4 # See LICENSE for details.
5
6
7 """
8 An example of using Twisted with Tkinter.
9 Displays a frame with buttons that responds to mouse clicks.
10
11 Run this example by typing in:
12  python tkinterdemo.py
13 """
14
15
16 from Tkinter import Tk, Frame, Button, LEFT
17 from twisted.internet import reactor, tksupport
18
19
20 class App(object):
21
22     def onQuit(self):
23         print "Quit!"
24         reactor.stop()
25
26     def onButton(self):
27         print "Hello!"
28
29     def __init__(self, master):
30         frame = Frame(master)
31         frame.pack()
32
33         q = Button(frame, text="Quit!", command=self.onQuit)
34         b = Button(frame, text="Hello!", command=self.onButton)
35
36         q.pack(side=LEFT)
37         b.pack(side=LEFT)
38
39
40 if __name__ == '__main__':
41     root = Tk()
42     tksupport.install(root)
43     app = App(root)
44     reactor.run()