Show More
@@ -1,37 +1,37 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 [1]: %gui gtk3 |
|
6 | In [1]: %gui gtk3 | |
7 |
|
7 | |||
8 | In [2]: %run gui-gtk3.py |
|
8 | In [2]: %run gui-gtk3.py | |
9 | """ |
|
9 | """ | |
10 |
|
10 | |||
11 | from gi.repository import Gtk |
|
11 | from gi.repository import Gtk | |
12 |
|
12 | |||
13 |
|
13 | |||
14 | def hello_world(wigdet, data=None): |
|
14 | def hello_world(wigdet, data=None): | |
15 |
print |
|
15 | print("Hello World") | |
16 |
|
16 | |||
17 | def delete_event(widget, event, data=None): |
|
17 | def delete_event(widget, event, data=None): | |
18 | return False |
|
18 | return False | |
19 |
|
19 | |||
20 | def destroy(widget, data=None): |
|
20 | def destroy(widget, data=None): | |
21 | Gtk.main_quit() |
|
21 | Gtk.main_quit() | |
22 |
|
22 | |||
23 | window = Gtk.Window(Gtk.WindowType.TOPLEVEL) |
|
23 | window = Gtk.Window(Gtk.WindowType.TOPLEVEL) | |
24 | window.connect("delete_event", delete_event) |
|
24 | window.connect("delete_event", delete_event) | |
25 | window.connect("destroy", destroy) |
|
25 | window.connect("destroy", destroy) | |
26 | button = Gtk.Button("Hello World") |
|
26 | button = Gtk.Button("Hello World") | |
27 | button.connect("clicked", hello_world, None) |
|
27 | button.connect("clicked", hello_world, None) | |
28 |
|
28 | |||
29 | window.add(button) |
|
29 | window.add(button) | |
30 | button.show() |
|
30 | button.show() | |
31 | window.show() |
|
31 | window.show() | |
32 |
|
32 | |||
33 | try: |
|
33 | try: | |
34 | from IPython.lib.inputhook import enable_gtk3 |
|
34 | from IPython.lib.inputhook import enable_gtk3 | |
35 | enable_gtk3() |
|
35 | enable_gtk3() | |
36 | except ImportError: |
|
36 | except ImportError: | |
37 | Gtk.main() |
|
37 | Gtk.main() |
General Comments 0
You need to be logged in to leave comments.
Login now