Created
March 6, 2012 18:16
-
-
Save prideout/1987871 to your computer and use it in GitHub Desktop.
Embed a VTE terminal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment