##// END OF EJS Templates
Minor work on the gtk example.
Brian Granger -
Show More
@@ -1,35 +1,43 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 """Simple GTK example to manually test event loop integration.
2 """Simple GTK example to manually test event loop integration.
3
3
4 This is meant to run tests manually in ipython as:
4 This is meant to run tests manually in ipython as:
5
5
6 In [5]: %gui gtk
6 In [5]: %gui gtk
7
7
8 In [6]: %run gui-gtk.py
8 In [6]: %run gui-gtk.py
9 """
9 """
10
10
11
11
12 import pygtk
12 import pygtk
13 pygtk.require('2.0')
13 pygtk.require('2.0')
14 import gtk
14 import gtk
15
15
16
16
17 def hello_world(wigdet, data=None):
17 def hello_world(wigdet, data=None):
18 print "Hello World"
18 print "Hello World"
19
19
20 def delete_event(widget, event, data=None):
21 return False
22
23 def destroy(widget, data=None):
24 gtk.main_quit()
25
20 window = gtk.Window(gtk.WINDOW_TOPLEVEL)
26 window = gtk.Window(gtk.WINDOW_TOPLEVEL)
27 self.window.connect("delete_event", delete_event)
28 self.window.connect("destroy", destroy)
21 button = gtk.Button("Hello World")
29 button = gtk.Button("Hello World")
22 button.connect("clicked", hello_world, None)
30 button.connect("clicked", hello_world, None)
23
31
24 window.add(self.button)
32 window.add(button)
25 button.show()
33 button.show()
26 window.show()
34 window.show()
27
35
28 try:
36 try:
29 from IPython.lib.inputhook import appstart_gtk
37 from IPython.lib.inputhook import appstart_gtk
30 appstart_gtk()
38 appstart_gtk()
31 except ImportError:
39 except ImportError:
32 gtk.main()
40 gtk.main()
33
41
34
42
35
43
General Comments 0
You need to be logged in to leave comments. Login now