-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.py
42 lines (33 loc) · 1.01 KB
/
test.py
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
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
# [SNIPPET_NAME: Embed a VTE terminal]
# [SNIPPET_CATEGORIES: Python VTE]
# [SNIPPET_DESCRIPTION: Embed a VTE terminal in your application]
import sys
from gi.repository import Gdk
try:
import gtk
except:
print >> sys.stderr, "You need to install the python gtk bindings"
sys.exit(1)
# import vte
try:
import vte
except:
error = gtk.MessageDialog (None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
'You need to install python bindings for libvte')
error.run()
sys.exit (1)
if __name__ == '__main__':
# create the terminal
v = vte.Terminal()
v.connect ("child-exited", lambda term: gtk.main_quit())
# fork_command() will run a command, in this case it shows a prompt
v.fork_command()
# create a window and add the VTE
window = gtk.Window()
window.add(v)
window.connect('delete-event', lambda window, event: gtk.main_quit())
# you need to show the VTE
window.show_all()
# Finally, run the application
gtk.main()