- 论坛徽章:
- 0
|
用VTE可心不?- #!/usr/bin/env python
- import os
- import gtk
- import vte
- import time
- from subprocess import Popen, PIPE
- def show_callback(terminal):
- terminal.feed_child('cd /\n')
- terminal.feed_child('whoami\n')
- terminal.feed_child('echo test\n')
- for ii in range (3):
- terminal.feed_child('echo ' + str(ii + 1) + '\n')
- terminal.feed_child('vi http.py\n')
- def write(terminal, text):
- x, y = terminal.get_cursor_position()
- terminal.feed(text + '\n', len(text) + 1)
- window = gtk.Window()
- window.connect('destroy', lambda w: gtk.main_quit())
- terminal = vte.Terminal()
- terminal.connect("show", show_callback)
- child_pid = terminal.fork_command()
- #write(terminal, '1234567890')
- window.add(terminal)
- window.show_all()
- gtk.main()
复制代码 |
|