def terminal_gui(self, current=None): self.scrolledwindow = Gtk.ScrolledWindow() self.terminal = Vte.Terminal() #self.terminal.set_sensitive(False) self.tbox.pack_start(self.scrolledwindow, True, True, 0) self.terminal.connect("eof", self.quit_) self.terminal.connect("current-directory-uri-changed", self.on_current_directory_uri_changed) self.terminal.set_cursor_shape(Vte.CursorShape(self.cursorshape[0])) self.terminal.set_color_background(self.bg_color) self.terminal.set_color_cursor(self.cursorcolor) #self.terminal.set_color_foreground(self.foreground) if self.fontsize: self.terminal.set_font(self.fontsize[0]) self.terminal.set_allow_hyperlink(True) vadjustment = self.terminal.get_vadjustment() self.scrolledwindow.set_vadjustment(vadjustment) self.user_info = pwd.getpwuid(os.geteuid()) text = self.entry.props.text if current: current_dir = current else: current_dir = self.user_info.pw_dir if text: t = subprocess.check_output( "export PS1=\"{}\";echo $PS1".format(text), shell=True).decode("utf-8")[:-1] self.terminal.spawn_sync(Vte.PtyFlags.DEFAULT, current_dir, ["/usr/bin/bash"], ["export", "PS1={}".format(t)], GLib.SpawnFlags.DO_NOT_REAP_CHILD, None, None) else: self.terminal.spawn_sync(Vte.PtyFlags.DEFAULT, current_dir, ["/usr/bin/bash"], [], GLib.SpawnFlags.DO_NOT_REAP_CHILD, None, None) self.scrolledwindow.add(self.terminal) self.terminal.connect("button-release-event", self.on_button_event) self.show_all()
def on_radio_button_toggled(self, b, data): self.t[0] = data self.terminal.set_cursor_shape(Vte.CursorShape(data))