import vte
import gtk
class Terminal (vte.Terminal):
def destroy(self, action):
gtk.main_quit()
def restore_cb(self, action):
(text, attrs) = self.get_text(selected_cb, 1)
print "A portion of the text at restore-time is:"
print text
def __init__(self):
vte.Terminal.__init__(self)
command = None
self.set_cursor_blinks(0)
self.set_emulation('xterm')
self.set_font_from_string('monospace 12')
self.set_scrollback_lines(5000)
self.set_audible_bell(0)
self.set_visible_bell(0)
self.connect("restore-window", self.restore_cb)
self.connect("child-exited", self.destroy)
if (command):
child_pid = self.fork_command(command)
else:
child_pid = self.fork_command()
self.show()
class Window (gtk.Window):
def destroy(self, action):
gtk.main_quit()
def __init__(self):
gtk.Window.__init__(self)
terminal = Terminal()
hbox = gtk.VBox()
hbox.pack_start(terminal, False, False)
self.connect("destroy", self.destroy)
self.set_title("Dumb Term.")
self.add(hbox)
self.show_all()
if __name__ == "__main__":
init = Window()
try:
gtk.main()
except KeyboardInterrupt:
raise SystemExit