Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question
    
you have that long line a bunch of times or just once? –  hbdgaf Jun 25 '12 at 5:57
1  
just once right now but I want to add them dynamically in the future. –  int_ua Jun 25 '12 at 11:51
add comment

2 Answers

up vote 6 down vote accepted
+100

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.fork_command_full(
    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()
share|improve this answer
    
Thanks :) waiting 11 hours till bounty can be awarded. –  int_ua Jun 25 '12 at 11:49
add comment

Building on ADcomp's answer to address wanting to add them dynamically in the future, I think you might want to subclass Vte.terminal.

#!/usr/bin/env python

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

class MyTerm(Vte.Terminal):
    def __init__(self, *args, **kwds):
        super(MyTerm, self).__init__(*args, **kwds)
        self.fork_command_full(
            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)
bigbox = Gtk.Box()
win.add(bigbox)
bigbox.add(MyTerm())
bigbox.add(MyTerm())
win.show_all()

Gtk.main()
share|improve this answer
    
Thanks :) __init__(self, command) would be even nicer, I'll try this later. –  int_ua Jun 26 '12 at 12:40
    
I think you mean you want **kwds in there –  hbdgaf Jun 26 '12 at 17:32
    
@int_ua - more what you wanted? i thought you were just looking to embed a term from the context of the question –  hbdgaf Jun 26 '12 at 17:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.