to execute shell script commands and get the output you really don't need the terminal you could do something like "subprocess.check_output" which will execute the command and get the output... after getting the output you could print it in a text view
class LabelWindow(Gtk.Window):
def on_clicked(self, button , data):
result = subprocess.check_output(['ls'])
data.set_text(result)
def __init__(self):
Gtk.Window.__init__(self, title="Label Example")
hbox = Gtk.Box(spacing=10)
hbox.set_homogeneous(False)
vbox_left = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
vbox_left.set_homogeneous(False)
vbox_right = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
vbox_right.set_homogeneous(False)
hbox.pack_start(vbox_left, True, True, 0)
hbox.pack_start(vbox_right, True, True, 0)
label = Gtk.Label(label="This is a normal label")
vbox_left.pack_start(label, True, True, 0)
button = Gtk.Button(label="Click at your own risk")
label.set_mnemonic_widget(button)
vbox_right.pack_start(button, True, True, 0)
button.connect("clicked", self.on_clicked, label)
self.add(hbox)
window = LabelWindow()
window.connect("destroy", Gtk.main_quit)
window.show_all()
Gtk.main()
this is a very rough example.. but if each button has will execute a command synchronously like one after another then you could create more button and add the specific command to each of em. if you want them to be executed asynchronously like one should not wait for another means add threads and use glib.idle_add Python GTK+ 3 Safe Threading