Python Forum
[GTK] Virtual python shell with Vte.Pty.spawn_async()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[GTK] Virtual python shell with Vte.Pty.spawn_async()
#2
I find some mistakes in my code, now it is working great, there is final solution:

import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Vte', '2.91')
from gi.repository import Gtk, Vte, GLib, Pango, Gio

class TheWindow(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self, title="GTK3 IDE")
        self.set_default_size(600, 300)

        terminal = Vte.Terminal()
        #pty = terminal.pty_new_sync(Vte.PtyFlags.DEFAULT)
        pty = Vte.Pty.new_sync(Vte.PtyFlags.DEFAULT)
        terminal.set_pty(pty)

        pty.spawn_async(
            None,
            ["/bin/python"],
            None,
            GLib.SpawnFlags.DO_NOT_REAP_CHILD,
            None,
            None,
            -1,
            None,
            self.ready
            )

        #self.terminal.get_pty(self.pty)

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        scroller = Gtk.ScrolledWindow()
        scroller.set_hexpand(True)
        scroller.set_vexpand(True)
        scroller.add(terminal)
        box.pack_start(scroller, False, True, 2)
        self.add(box)

    def ready(self, pty, task):
        print('pty ', pty)


win=TheWindow()
win.connect('destroy', Gtk.main_quit)
win.show_all()
Gtk.main()
Reply


Messages In This Thread
RE: [GTK] Virtual python shell with Vte.Pty.spawn_async() - by jiri - Mar-14-2019, 08:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Tkinter Shell Terminal Or Shell Output sweetthdevil 5 13,230 Feb-03-2024, 02:51 PM
Last Post: Gribouillis
  [Tkinter] Display on gui instead of Python shell Justin 2 5,037 Mar-05-2017, 06:33 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020