我尝试使用Vte终端小部件来显示python脚本中的文本。在
我没有设置工作目录或模拟器,我只是想要一个空的终端来处理文本和ansi转义序列
我有这段代码,它在python 2.7中工作:
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Vte', '2.91')
from gi.repository import Gtk, Vte
from gi.repository import GLib
import os
terminal = Vte.Terminal()
terminal.spawn_sync(
Vte.PtyFlags.DEFAULT,
None,
[],
[],
GLib.SpawnFlags.DO_NOT_REAP_CHILD,
None,
None,
)
win = Gtk.Window()
win.connect('delete-event', Gtk.main_quit)
win.add(terminal)
win.show_all()
terminal.feed('hello') #string to display
Gtk.main()
但它在python3.5中不起作用,我得到的只是一个空白的终端。在
以下是显示文本的正确方法:
顺便说一下,这容易多了。在
编辑:包括颜色。在
相关问题 更多 >
编程相关推荐