/
test_vte_get_text_2.py
46 lines (37 loc) · 1.37 KB
/
test_vte_get_text_2.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
43
44
45
46
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GLib
from gi.repository import Vte
import os
class TestVte(Gtk.Window):
def __init__(self):
super(TestVte, self).__init__()
self.set_size_request(400, 400)
self.connect("destroy", Gtk.main_quit)
vbox = Gtk.VBox()
self.vte = Vte.Terminal()
vbox.add(self.vte)
self.vte.set_colors(Gdk.color_parse('#000000'),
Gdk.color_parse('#FFFFFF'), [])
self.vte.set_emulation('xterm')
sucess_, pid = self.vte.fork_command_full(Vte.PtyFlags.DEFAULT,
os.environ["HOME"],
["/bin/bash"],
[],
GLib.SpawnFlags.DO_NOT_REAP_CHILD,
None,
None)
button1 = Gtk.Button('Get text')
button1.connect('clicked', self.__get_text_cb)
vbox.add(button1)
self.add(vbox)
self.show_all()
def is_selected(self, vte, *args):
return True
def __get_text_cb(self, button):
#self.attrs = GLib.Array()
text = self.vte.get_text(self.is_selected, None)
print text
#print self.attrs
TestVte()
Gtk.main()