Python gtk 模块,Notebook() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用gtk.Notebook()

项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def check_notebook_pages(self, widget):
        if widget.get_n_pages()==0:
            #eliminar el notebook solo si queda otro notebook y no quedan tabs en el actual            
            paned = widget.get_parent()            
            if paned==None or paned==self.hpMain:
                return
            container = paned.get_parent()
            save = paned.get_child2() if paned.get_child1()==widget else paned.get_child1()    
            container.remove(paned)
            paned.remove(save)
            container.add(save)
            if widget == self.nbConsole:                
                if isinstance(save, gtk.Notebook):
                    self.nbConsole = save
                else:
                    self.nbConsole = self.find_notebook(save)
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def _setup_ui(self):
        self.set_has_separator(False)

        self.tab = gtk.Notebook()
        self.vbox.pack_start(self.tab, fill=True, expand=True)
        self._setup_ui_sources()
        self._setup_ui_advanced()
        self._setup_ui_player_conf()
        self.tab.show()
    # _setup_ui()
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def find_notebook(self, widget, exclude=None):
        if widget!=exclude and isinstance(widget, gtk.Notebook):
            return widget
        else:
            if not hasattr(widget, "get_children"):
                return None
            for w in widget.get_children():
                wid = self.find_notebook(w, exclude)
                if wid!=exclude and isinstance(wid, gtk.Notebook):
                    return wid
            return None
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def on_double_click(self, widget, event, *args):
        if event.type in [gtk.gdk._2BUTTON_PRESS, gtk.gdk._3BUTTON_PRESS] and event.button == 1:
            if isinstance(widget, gtk.Notebook):
                pos = event.x + widget.get_allocation().x
                size = widget.get_tab_label(widget.get_nth_page(widget.get_n_pages()-1)).get_allocation()
                if pos <= size.x + size.width + 2 * widget.get_property("tab-vborder") + 8 or event.x >= widget.get_allocation().width - widget.style_get_property("scroll-arrow-hlength"):
                    return True
            self.addTab(widget if isinstance(widget, gtk.Notebook) else self.nbConsole, 'local')
            return True
    #-- Wmain.on_double_click }

    #-- Wmain.on_btnLocal_clicked {
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def on_btnLocal_clicked(self, widget, *args):        
        if self.current != None and self.current.get_parent()!=None and isinstance(self.current.get_parent().get_parent(), gtk.Notebook):
            ntbk = self.current.get_parent().get_parent()
        else:
            ntbk = self.nbConsole
        self.addTab(ntbk, 'local')
    #-- Wmain.on_btnLocal_clicked }

    #-- Wmain.on_btnConnect_clicked {
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def make_tabs(self):
        self.tabs = gtk.Notebook()
        self.tabs.set_scrollable(True)

        return self.tabs
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def __init__(self, rthread):
        super(SettingsEditor, self).__init__(rthread)

        # The main box
        self.root = gtk.HBox(False, 0)

        # The pane
        paned = gtk.HPaned()
        paned.show()
        self.root.pack_start(paned, 1, 1, 0)

        # The selection tree
        self._store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_INT)
        self._view = gtk.TreeView(self._store)
        self._view.get_selection().connect("changed", self._view_changed_cb)
        self._view.append_column(
            gtk.TreeViewColumn("", gtk.CellRendererText(), text=0))
        self._view.show()
        scrolled_window = gtk.ScrolledWindow()
        scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scrolled_window.add_with_viewport(self._view)
        scrolled_window.set_size_request(200, -1)
        scrolled_window.show()
        paned.pack1(scrolled_window)

        # The settings notebook
        self._notebook = gtk.Notebook()
        self._notebook.set_show_tabs(False)
        self._notebook.set_show_border(False)
        self._notebook.show()
        paned.pack2(self._notebook)

        self._changed = False
        self._settings = None

        job = common.RadioJob(self._get_settings_cb, "get_settings")
        job.set_desc("Getting radio settings")
        self.rthread.submit(job)
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def split_notebook(self, direction):        
        csp = self.current.get_parent() if self.current!=None else None
        cnb = csp.get_parent() if csp!=None else None

        #Separar solo si hay mas de 2 tabs en el notebook actual
        if csp!=None and cnb.get_n_pages()>1:
            #Crear un hpaned, en el hijo 0 dejar el notebook y en el hijo 1 el nuevo notebook
            #El nuevo hpaned dejarlo como hijo del actual parent
            hp = gtk.HPaned() if direction==HSPLIT else gtk.VPaned()
            nb = gtk.Notebook()
            nb.set_group_id(11)
            nb.connect('button_press_event', self.on_double_click, None)
            nb.connect('page_removed', self.on_page_removed)
            nb.connect("page-added", self.on_page_added)
            nb.set_property("scrollable", True)
            cp  = cnb.get_parent()

            if direction==HSPLIT:
                cnb.set_size_request(cnb.allocation.width/2, cnb.allocation.height)
            else:                
                cnb.set_size_request(cnb.allocation.width, cnb.allocation.height/2)
            #cnb.set_size_request(cnb.allocation.width/2, cnb.allocation.height/2)

            cp.remove(cnb)
            cp.add(hp)
            hp.add1(cnb)                        

            text = cnb.get_tab_label(csp).get_text()

            csp.reparent(nb)
            csp = nb.get_nth_page(0)

            tab = NotebookTabLabel(text, nb, csp, self.popupMenuTab)
            nb.set_tab_label(csp, tab_label=tab)
            nb.set_tab_reorderable(csp, True)
            nb.set_tab_detachable(csp, True)

            hp.add2(nb)
            nb.show()
            hp.show()
            hp.queue_draw()
            self.current = cnb.get_nth_page(cnb.get_current_page()).get_children()[0]