Tuesday, April 30, 2024
 Popular · Latest · Hot · Upcoming
16
rated 0 times [  16] [ 0]  / answers: 1 / hits: 9085  / 1 Year ago, wed, march 15, 2023, 4:55:30

I'm trying to add vte widget in my application and the examples I've found use .fork_command() to execute a command in that widget.
But according to



http://developer.gnome.org/vte/0.26/VteTerminal.html#vte-terminal-fork-command



it was deprecated and it's recommended to use fork_command_full(). Which needs eight mandatory arguments. Haven't they heard the "defaults" word? I've been able to construct lines that work somehow:



pty_flags = vte.PtyFlags(0)
terminal.fork_command_full(pty_flags, "/home/int", ("/bin/bash", ), "", 0, None, None)


Yes, I know about the enums, I just hope that I'm doing this completely wrong and there is a much easier way. Do you know any?



P.S. I'm using quickly with the default ubuntu-application template.



P.P.S. The import line is from gi.repository import Vte as vte


More From » python

 Answers
6

Here a basic example:



#!/usr/bin/env python

from gi.repository import Gtk, Vte
from gi.repository import GLib
import os

terminal = Vte.Terminal()
terminal.spawn_sync(
Vte.PtyFlags.DEFAULT,
os.environ['HOME'],
["/bin/sh"],
[],
GLib.SpawnFlags.DO_NOT_REAP_CHILD,
None,
None,
)

win = Gtk.Window()
win.connect('delete-event', Gtk.main_quit)
win.add(terminal)
win.show_all()

Gtk.main()

[#37381] Thursday, March 16, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
berlorful

Total Points: 346
Total Questions: 90
Total Answers: 99

Location: Monaco
Member since Tue, Nov 30, 2021
2 Years ago
berlorful questions
Thu, Sep 2, 21, 10:12, 3 Years ago
Sun, May 9, 21, 20:55, 3 Years ago
Mon, Jan 16, 23, 23:19, 1 Year ago
Mon, Aug 29, 22, 05:43, 2 Years ago
;