Пример #1
0
    def __reset(self, archivo=None):
        """
        Reseteo de la Terminal.
        """

        if archivo:
            interprete = "/bin/bash"

            try:
                import mimetypes

                if "python" in mimetypes.guess_type(archivo)[0]:
                    interprete = "python"

                    if os.path.exists(os.path.join("/bin", interprete)):
                        interprete = os.path.join("/bin", interprete)

                    elif os.path.exists(os.path.join("/usr/bin", interprete)):
                        interprete = os.path.join("/usr/bin", interprete)

                    elif os.path.exists(os.path.join("/sbin", interprete)):
                        interprete = os.path.join("/sbin", interprete)

                    elif os.path.exists(os.path.join("/usr/local",
                                                     interprete)):
                        interprete = os.path.join("/usr/local", interprete)

            except:
                ### Cuando se intenta ejecutar un archivo no ejecutable.
                return self.set_interprete()

            path = os.path.dirname(archivo)

            pty_flags = Vte.PtyFlags(0)

            self.fork_command_full(pty_flags, path, (interprete, archivo), "",
                                   0, None, None)

        else:
            interprete = self.interprete
            path = self.path

            pty_flags = Vte.PtyFlags(0)

            self.fork_command_full(pty_flags, path, (interprete, ), "", 0,
                                   None, None)

        self.child_focus(True)
Пример #2
0
 def reset(self, path=os.environ["HOME"], interprete="/bin/bash"):
     pty_flags = Vte.PtyFlags(0)
     try:
         self.fork_command_full(pty_flags, path, (interprete, ), "", 0,
                                None, None)
     except:
         self.spawn_sync(pty_flags, path, (interprete, ), "", 0, None, None)
     self.child_focus(True)
Пример #3
0
    def ejecute_script(self, dirpath, interprete, path_script, param):
        """
        Ejecuta un script con parámetros, en la terminal activa

        Por ejemplo:
            python setup.py sdist

            dirpath     =   directorio base donde se encuentra setup.py
            interprete  =   python en este caso
            path_script =   dirpath + 'setup.py'
            param       =   'sdist' en est caso
        """
        terminal = self.notebook.get_children()[
            self.notebook.get_current_page()].get_child()

        pty_flags = Vte.PtyFlags(0)
        terminal.fork_command_full(pty_flags, dirpath,
            (interprete, path_script, param), "", 0, None, None)
Пример #4
0
    def ejecute_script(self, dirpath, interprete, path_script, param):
        """
        Ejecuta un script con parámetros, en la terminal activa
        Por ejemplo:
            python setup.py sdist

            dirpath     =   directorio base donde se encuentra setup.py
            interprete  =   python en este caso
            path_script =   dirpath + 'setup.py'
            param       =   'sdist' en est caso
        """
        pty_flags = Vte.PtyFlags(0)
        try:
            self.fork_command_full(pty_flags, dirpath,
                                   (interprete, path_script, param), "", 0,
                                   None, None)
        except:
            self.spawn_sync(pty_flags, dirpath,
                            (interprete, path_script, param), "", 0, None,
                            None)
    def init(self):
        self.all_category = {}
        self.switchcategory = {}

        self.sw = Gtk.ScrolledWindow()
        self.maincontainer = Gtk.VBox()
        self.grid = Gtk.Grid()
        self.stack = Gtk.Stack()
        self.stack.set_hexpand(True)
        self.stack.set_vexpand(True)
        self.listbox_ = Gtk.ListBox()

        self.grid.attach(self.listbox_, 0, 0, 1, 1)
        self.grid.attach(self.stack, 1, 0, 1, 1)
        self.maincontainer.add(self.grid)
        self.sw.add(self.maincontainer)
        self.add(self.sw)

        self.loading_all_plugins()

        self.listbox_.connect("row-activated", self.on_activated_row)
        try:
            gi.require_version('Vte', '2.91')
            from gi.repository import Vte
            tscrolledwindow = Gtk.ScrolledWindow()
            self.terminal = Vte.Terminal()

            #self.terminal.set_color_background(Gdk.RGBA(red=0.180392, green=0.203922, blue=0.211765, alpha=1.000000))
            self.terminal.set_color_foreground(
                Gdk.RGBA(red=0.988235,
                         green=0.913725,
                         blue=0.309804,
                         alpha=1.000000))
            vadjustment = self.terminal.get_vadjustment()
            tscrolledwindow.set_vadjustment(vadjustment)
            _pty = Vte.Pty.new_sync(Vte.PtyFlags(0), None)
            _pty.child_setup()
            self.terminal.set_pty(_pty)

            self.terminal.connect("button-release-event", self.on_button_event)

            self.menu = Gtk.Menu()
            self.menu.set_screen(Gdk.Screen().get_default())

            self.copytextmenuitem = Gtk.MenuItem.new_with_label("Copy")
            cursorcolormenuitem = Gtk.MenuItem.new_with_label("Cursor Color")
            backgroundmenuitem = Gtk.MenuItem.new_with_label("Backgound Color")
            foregroundmenuitem = Gtk.MenuItem.new_with_label(
                "Foreground Color")

            self.copytextmenuitem.connect("activate", self.copy_text)
            cursorcolormenuitem.connect("activate",
                                        self.on_cursor_menuitem_activated)
            backgroundmenuitem.connect("activate",
                                       self.on_background_menuitem_activated)
            foregroundmenuitem.connect("activate",
                                       self.on_foreground_menuitem_activated)

            self.menu.append(self.copytextmenuitem)
            self.menu.append(cursorcolormenuitem)
            self.menu.append(backgroundmenuitem)
            self.menu.append(foregroundmenuitem)

            self.vte_format = Vte.Format(1)
            tscrolledwindow.add(self.terminal)
            self.maincontainer.pack_end(tscrolledwindow, True, True, 0)
        except Exception as e:
            print(e)
        self.show_all()