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

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

项目:zim-icontags-plugin    作者:Pl-M    | 项目源码 | 文件源码
def on_populate_popup(self, treeview, menu):
        '''Add popup menu options.'''
        menu.prepend(gtk.SeparatorMenuItem())

        # Add menu with view options.
        view_menu = gtk.Menu()
        # Add options to show tags and tagged pages.
        items = ( (_('Show only Pages with Tags'), self._show_tagged,
                   lambda o: self.toggle_show_tagged()),
                  (_('Show Tags'), self.uistate['show tags'],
                   lambda o: self.toggle_show_tags()) )
        for name, active, func in items:
            item = gtk.CheckMenuItem(name)
            item.set_active(active)
            item.connect('activate', func)
            view_menu.append(item)
        view_menu.append(gtk.SeparatorMenuItem())

        # Add options to switch between views.
        def _change_view(item, event):
            self.uistate['Open pages'] = item.zim_view
            self.treeview.change_view(self.uistate['Open pages'])

        items = ( (_('Default'), 'default'),
                  (_('Collapse other Pages'), 'collapse'),
                  (_('Disable'), 'disable') )
        item = None
        for name, view in items:
            item = gtk.RadioMenuItem(group = item, label = name)
            if view == self.uistate['Open pages']:
                item.set_active(True)
            item.zim_view = view
            item.connect('button-release-event', _change_view)
            view_menu.append(item)

        item = gtk.MenuItem('View')
        item.set_submenu(view_menu)
        menu.prepend(item)

        menu.show_all()
项目:zim-icontags-plugin    作者:Pl-M    | 项目源码 | 文件源码
def do_initialize_popup(self, menu):
        '''
        Disable some items in popup menu for only tagged pages mode. 
        Although it is possible to leave it as is but it is not 
        recommended to create or change page names since not all pages 
        are shown.
        '''
        model = self.get_model()
        if not isinstance(model, gtk.TreeModelFilter):
            PageTreeView.do_initialize_popup(self, menu)
            return 

        path = self.get_selected_path() or Path(':')

        item = gtk.MenuItem(_('Open in New Window'))
        item.connect('activate', lambda o: self.ui.open_new_window(path))
        menu.append(item)

        menu.append(gtk.SeparatorMenuItem())

        item = gtk.ImageMenuItem('gtk-copy')
        item.connect('activate', lambda o: self.do_copy())
        menu.append(item)

        self.populate_popup_expand_collapse(menu)
        menu.show_all()
项目:zim-icontags-plugin    作者:Pl-M    | 项目源码 | 文件源码
def on_populate_popup(self, treeview, menu):
        '''Add popup menu options.'''
        menu.prepend(gtk.SeparatorMenuItem())

        # Add menu with view options.
        view_menu = gtk.Menu()
        # Add options to show tags and tagged pages.
        items = ( (_('Show only Pages with Tags'), self._show_tagged,
                   lambda o: self.toggle_show_tagged()),
                  (_('Show Tags'), self.uistate['show tags'],
                   lambda o: self.toggle_show_tags()) )
        for name, active, func in items:
            item = gtk.CheckMenuItem(name)
            item.set_active(active)
            item.connect('activate', func)
            view_menu.append(item)
        view_menu.append(gtk.SeparatorMenuItem())

        # Add options to switch between views.
        def _change_view(item, event):
            self.uistate['Open pages'] = item.zim_view
            self.treeview.change_view(self.uistate['Open pages'])

        items = ( (_('Default'), 'default'),
                  (_('Collapse other Pages'), 'collapse'),
                  (_('Disable'), 'disable') )
        item = None
        for name, view in items:
            item = gtk.RadioMenuItem(group = item, label = name)
            if view == self.uistate['Open pages']:
                item.set_active(True)
            item.zim_view = view
            item.connect('button-release-event', _change_view)
            view_menu.append(item)

        item = gtk.MenuItem('View')
        item.set_submenu(view_menu)
        menu.prepend(item)

        menu.show_all()
项目:zim-icontags-plugin    作者:Pl-M    | 项目源码 | 文件源码
def do_initialize_popup(self, menu):
        '''
        Disable some items in popup menu for only tagged pages mode.
        Although it is possible to leave it as is but it is not
        recommended to create or change page names since not all pages
        are shown.
        '''
        model = self.get_model()
        if not isinstance(model, gtk.TreeModelFilter):
            PageTreeView.do_initialize_popup(self, menu)
            return

        path = self.get_selected_path() or Path(':')

        item = gtk.MenuItem(_('Open in New Window'))
        item.connect('activate', lambda o: self.ui.open_new_window(path))
        menu.append(item)

        menu.append(gtk.SeparatorMenuItem())

        item = gtk.ImageMenuItem('gtk-copy')
        item.connect('activate', lambda o: self.do_copy())
        menu.append(item)

        self.populate_popup_expand_collapse(menu)
        menu.show_all()
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def _setup_menus(self):
        menu = gtk.Menu()

        item = gtk.MenuItem("Player")
        menu.append(item)
        item.show()
        submenu = gtk.Menu()
        if self.current_engine.menu_items:
            for wid in self.current_engine.menu_items:
                submenu.append(wid)
        item.set_submenu(submenu)
        submenu.show_all()

        def add_action(name):
            item = self.actions[name].create_menu_item()
            menu.append(item)
            item.show()

        item = gtk.MenuItem("Source")
        menu.append(item)
        item.show()
        submenu = gtk.Menu()
        for o in self.sources:
            if o.pretty_name:
                subitem = gtk.MenuItem(o.pretty_name)
                submenu.append(subitem)
                subitem.connect("activate", self._source_activated, o)
        item.set_submenu(submenu)
        submenu.show_all()

        add_action("Preferences")

        item = gtk.SeparatorMenuItem()
        menu.append(item)
        item.show()

        add_action("Quit")

        self.set_menu(menu)
        menu.show()
    # _setup_menus()
项目:bookmarks-indicator    作者:antoniocoratelli    | 项目源码 | 文件源码
def append_base_items(self):
        '''
        Append Quit, Restart and GitHub link items to the menu.
        '''
        s = gtk.SeparatorMenuItem()
        l = gtk.MenuItem("GitHub")
        r = gtk.MenuItem("Restart")
        q = gtk.MenuItem("Quit")
        l.connect("activate", self.onclick, "https://github.com/antoniocoratelli/bookmarks-indicator")
        r.connect("activate", self.restart)
        q.connect("activate", self.quit)
        for i in [s, l, r, q]: i.show(); self.menu.append(i)
项目:bookmarks-indicator    作者:antoniocoratelli    | 项目源码 | 文件源码
def append_separator(self, widget, name=None):
        '''
        Append a separator to a menu.
        '''
        sep = gtk.SeparatorMenuItem()
        sep.show()
        widget.append(sep)
        if name != None:
            sep_title = gtk.MenuItem(name)
            sep_title.set_sensitive(False)
            sep_title.show()
            widget.append(sep_title)
项目:wahcade    作者:sairuk    | 项目源码 | 文件源码
def setup_menu(self, mnu_items, mnu_pixmaps, activate_cb):
        """returns a gtk menu object
        Parameters:
            mnu_items   : List of menu item names (either a string, a gtk stock item or '_sep_' for a separator)
            mnu_pixmaps : List of pixmaps (filename, a gtk stock icon or None)
            activate_cb : Callback function for menu activation
        Returns:
            Reference to the constructed gtk.Menu
        """
        mnu = gtk.Menu()
        for i in range(len(mnu_items)):
            #separator or menu item?
            if mnu_items[i] != '_sep_':
                #menu item
                mnuItem = gtk.ImageMenuItem(stock_id=mnu_items[i])
                img = gtk.Image()
                if mnu_pixmaps[i]:
                    if mnu_pixmaps[i][:4] == 'gtk-' and '.' not in mnu_pixmaps[i]:
                        #stock icon
                        img.set_from_stock(mnu_pixmaps[i], gtk.ICON_SIZE_MENU)
                    else:
                        #file icon
                        img.set_from_pixbuf(self.get_pixbuf(mnu_pixmaps[i], gtk.ICON_SIZE_MENU))
                    img.show()
                    mnuItem.set_image(img)
                mnuItem.connect('activate', activate_cb)
                mnuItem.set_name(mnu_items[i])
            else:
                #separator
                mnuItem = gtk.SeparatorMenuItem()
            #add item to menu
            mnuItem.show()
            mnu.append(mnuItem)
        #done
        return mnu
项目:fluxgui    作者:xflux-gui    | 项目源码 | 文件源码
def add_menu_separator(self, menu, show=True):
        item = gtk.SeparatorMenuItem()
        menu.append(item)
        if show:
            item.show()
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def __init__(self, app_engine, gui):
        menu = gtk.Menu()

        # show main application
        main_application_menu_item = gtk.MenuItem("Main Application")
        main_application_menu_item.show()
        menu.append(main_application_menu_item)
        main_application_menu_item.connect('activate', self.show_main_gui, gui)

        #separator
        sep0 = gtk.SeparatorMenuItem()
        sep0.show()
        menu.append(sep0)

        for collector in app_engine.collectors:
            if isinstance(collector, engine.collector.ManualCollector):
                menu_item_collector = gtk.MenuItem(collector.command_description)
                menu.append(menu_item_collector)
                menu_item_collector.connect('activate', self.run_collector, collector)

        #separator
        sep1 = gtk.SeparatorMenuItem()
        sep1.show()
        menu.append(sep1)

        # show about_menu_item dialog
        self.startall_menu_item = gtk.MenuItem("Start All Collectors")
        self.startall_menu_item.show()
        menu.append(self.startall_menu_item)
        self.startall_menu_item.connect('activate', gui.startall_collectors)

        # show about_menu_item dialog
        self.stopall_menu_item = gtk.MenuItem("Stop All Collectors")
        self.stopall_menu_item.show()
        menu.append(self.stopall_menu_item)
        self.stopall_menu_item.connect('activate', gui.stopall_collectors)
        self.stopall_menu_item.set_sensitive(False)

        #separator
        sep2 = gtk.SeparatorMenuItem()
        sep2.show()
        menu.append(sep2)

        # show about_menu_item dialog
        about_menu_item = gtk.MenuItem("About")
        about_menu_item.show()
        menu.append(about_menu_item)
        about_menu_item.connect('activate', self.show_about_dialog)

        # add quit_menu_item item
        quit_menu_item = gtk.MenuItem("Quit")
        quit_menu_item.show()
        menu.append(quit_menu_item)
        quit_menu_item.connect('activate', self.kill_me, app_engine)

        self.tray_ind = appindicator.Indicator("ECEL", gtk.STOCK_NO, appindicator.CATEGORY_SYSTEM_SERVICES)
        self.tray_ind.set_status(appindicator.STATUS_ACTIVE)
        self.tray_ind.set_menu(menu)

        menu.show_all()
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def add_catalog_items(self, menu_add):

        def add_to_menu(grp_menu, path) :
            for ptr in range(len(path)) :
                try :
                    p = path[ptr]
                    if p.tag.lower() in ["menu", "menuitem", "group", "sub"] :
                        name = p.get("name") if "name" in p.keys() else ""
                        a_menu_item = gtk.ImageMenuItem(_(name))

                        tooltip = _(p.get("tool_tip")) if "tool_tip" in p.keys() else None
                        if (tooltip is not None) and (tooltip != '') :
                            a_menu_item.set_tooltip_markup(_(tooltip))

                        icon = p.get('icon')
                        if icon is not None :
                            img = gtk.Image()
                            img.set_from_pixbuf(get_pixbuf(icon, add_menu_icon_size))
                            a_menu_item.set_image(img)

                        src = p.get('src')
                        if src is not None :
                            a_menu_item.connect("activate", self.add_feature, src)

                        grp_menu.append(a_menu_item)

                        if p.tag.lower() in ['menu', "group"] :
                            a_menu = gtk.Menu()
                            a_menu_item.set_submenu(a_menu)
                            add_to_menu(a_menu, p)

                    elif p.tag.lower() == "separator":
                        grp_menu.append(gtk.SeparatorMenuItem())
                except:
                    pass

        if self.catalog.tag != 'ncam_ui' :
            mess_dlg(_('Menu is old format, no toolbar defined.\nUpdate to new format'))
            add_to_menu(menu_add, self.catalog)
        else :
            for _ptr in range(len(self.catalog)) :
                _p = self.catalog[_ptr]
                if _p.tag.lower() in ["menu", "group"] :
                    add_to_menu(menu_add, _p)