当前位置: 首页>>代码示例>>Python>>正文


Python gtk.ImageMenuItem方法代码示例

本文整理汇总了Python中gtk.ImageMenuItem方法的典型用法代码示例。如果您正苦于以下问题:Python gtk.ImageMenuItem方法的具体用法?Python gtk.ImageMenuItem怎么用?Python gtk.ImageMenuItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gtk的用法示例。


在下文中一共展示了gtk.ImageMenuItem方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: enable

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import ImageMenuItem [as 别名]
def enable(self):
        """actions to take on plugin enabled.
        loads preference page, and context menu.
        """
        self.server_plugin_version = (1, 1, 12)
        self.config_ui = ConfigUI()
        component.get("Preferences").add_page("FileBotTool", self.config_ui.config_page)
        component.get("PluginManager").register_hook("on_apply_prefs",
                                                     self.on_apply_prefs)
        component.get("PluginManager").register_hook("on_show_prefs", self.on_show_prefs)

        # add context menu item for FileBotTool
        torrentmenu = component.get("MenuBar").torrentmenu
        self.menu_item = gtk.ImageMenuItem("FileBotTool")
        img = gtk.image_new_from_file(get_resource("fb_icon16.png"))
        self.menu_item.set_image(img)
        self.menu_item.connect("activate", self.get_torrent_info)
        torrentmenu.append(self.menu_item)
        torrentmenu.show_all()
        self.get_server_plugin_version() 
开发者ID:Laharah,项目名称:deluge-FileBotTool,代码行数:22,代码来源:gtkui.py

示例2: callback

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import ImageMenuItem [as 别名]
def callback(self, menuitems, menu, terminal):
        """Add our menu items to the menu"""
        item = gtk.MenuItem(_('Custom Commands'))
        menuitems.append(item)

        submenu = gtk.Menu()
        item.set_submenu(submenu)

        menuitem = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
        menuitem.connect("activate", self.configure)
        submenu.append(menuitem)

        menuitem = gtk.SeparatorMenuItem()
        submenu.append(menuitem)

        theme = gtk.IconTheme()
        for command in self.cmd_list:
          if not command['enabled']:
            continue
          exe = command['command'].split(' ')[0]
          iconinfo = theme.choose_icon([exe], gtk.ICON_SIZE_MENU, gtk.ICON_LOOKUP_USE_BUILTIN)
          if iconinfo:
            image = gtk.Image()
            image.set_from_icon_name(exe, gtk.ICON_SIZE_MENU)
            menuitem = gtk.ImageMenuItem(command['name'])
            menuitem.set_image(image)
          else:
            menuitem = gtk.MenuItem(command["name"])
          menuitem.connect("activate", self._execute, {'terminal' : terminal, 'command' : command['command'] })
          submenu.append(menuitem) 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:32,代码来源:custom_commands.py

示例3: addField

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import ImageMenuItem [as 别名]
def addField(self, pathstr, callback=None, args=(), stockid=None):
        parent = self.menu
        kid = None
        plist = pathstr.split(self.splitchar)

        for p in plist[:-1]:
            kid = parent.kids.get(p)
            if kid == None:
                item = gtk.MenuItem(p, True)
                item.set_name("vwidget_menu")
                item.show()
                parent.insert(item, parent.idx)
                parent.idx += 1
                kid = Menu()
                kid.idx = 0
                item.set_submenu(kid)
                parent.kids[p] = kid
            parent = kid

        if stockid != None:
            item = gtk.ImageMenuItem(stock_id=stockid)
        else:
            item = gtk.MenuItem(plist[-1], True)
        if callback != None:
            item.connect("activate", callback, *args)

        item.show()
        item.set_name("vwidget_menu")
        parent.insert(item, parent.idx)
        parent.idx += 1
        #parent.append(item)
        return item 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:34,代码来源:menubuilder.py

示例4: sub_menu

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import ImageMenuItem [as 别名]
def sub_menu(self):
        """Create daemon submenu
        """
        submenu = gtk.Menu()
        self.start = gtk.ImageMenuItem("Start")
        self.stop = gtk.ImageMenuItem("Stop")
        self.restart = gtk.ImageMenuItem("Restart")
        self.status = gtk.ImageMenuItem("Status")

        self.start.show()
        self.stop.show()
        self.restart.show()
        self.status.show()

        img_Start = gtk.image_new_from_stock(gtk.STOCK_MEDIA_PLAY,
                                             gtk.ICON_SIZE_MENU)
        img_Start.show()
        self.start.set_image(img_Start)

        img_Stop = gtk.image_new_from_stock(gtk.STOCK_STOP,
                                            gtk.ICON_SIZE_MENU)
        img_Stop.show()
        self.stop.set_image(img_Stop)

        img_Restart = gtk.image_new_from_stock(gtk.STOCK_REFRESH,
                                               gtk.ICON_SIZE_MENU)
        img_Restart.show()
        self.restart.set_image(img_Restart)

        img_Status = gtk.image_new_from_stock(gtk.STOCK_DIALOG_QUESTION,
                                              gtk.ICON_SIZE_MENU)
        img_Status.show()
        self.status.set_image(img_Status)

        submenu.append(self.start)
        submenu.append(self.stop)
        submenu.append(self.restart)
        submenu.append(self.status)

        self.daemon = gtk.ImageMenuItem("Daemon")
        self.img_daemon = gtk.image_new_from_stock(self.daemon_STOCK,
                                                   gtk.ICON_SIZE_MENU)
        self.img_daemon.show()
        self.daemon.set_submenu(submenu) 
开发者ID:dslackw,项目名称:sun,代码行数:46,代码来源:status_icon_gtk2.py

示例5: menu

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import ImageMenuItem [as 别名]
def menu(self, event_button, event_time, data=None):
        """Create popup menu
        """
        self.sub_menu()
        menu = gtk.Menu()
        menu.append(self.daemon)

        separator = gtk.SeparatorMenuItem()

        menu_Check = gtk.ImageMenuItem("Check updates")
        img_Check = gtk.image_new_from_stock(gtk.STOCK_OK,
                                             gtk.ICON_SIZE_MENU)
        img_Check.show()

        menu_Info = gtk.ImageMenuItem("OS Info")
        img_Info = gtk.image_new_from_stock(gtk.STOCK_INFO,
                                            gtk.ICON_SIZE_MENU)
        img_Info.show()

        menu_About = gtk.ImageMenuItem("About")
        img_About = gtk.image_new_from_stock(gtk.STOCK_ABOUT,
                                             gtk.ICON_SIZE_MENU)
        img_About.show()

        self.daemon.set_image(self.img_daemon)
        menu.append(self.daemon)
        self.daemon.show()

        menu_Quit = gtk.ImageMenuItem("Quit")
        img_Quit = gtk.image_new_from_stock(gtk.STOCK_QUIT, gtk.ICON_SIZE_MENU)
        img_Quit.show()

        menu_Check.set_image(img_Check)
        menu_Info.set_image(img_Info)
        menu_About.set_image(img_About)
        menu_Quit.set_image(img_Quit)

        menu.append(menu_Check)
        menu.append(menu_Info)
        menu.append(separator)
        menu.append(menu_About)
        menu.append(menu_Quit)

        separator.show()
        menu_Check.show()
        menu_Info.show()
        menu_About.show()
        menu_Quit.show()

        menu_Check.connect_object("activate", self._Check, " ")
        menu_Info.connect_object("activate", self._Info, "OS Info")
        menu_About.connect_object("activate", self._About, "SUN")
        self.start.connect_object("activate", self._start, "Start daemon   ")
        self.stop.connect_object("activate", self._stop, "Stop daemon   ")
        self.restart.connect_object("activate", self._restart,
                                    "Restart daemon   ")
        self.status.connect_object("activate", self._status, daemon_status())
        menu_Quit.connect_object("activate", self._Quit, "stop")

        menu.popup(None, None, None, event_button, event_time, data) 
开发者ID:dslackw,项目名称:sun,代码行数:62,代码来源:status_icon_gtk2.py

示例6: updateTree

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import ImageMenuItem [as 别名]
def updateTree(self):
        for grupo in dict(groups):
            if len(groups[grupo])==0:
                del groups[grupo]
        
        if conf.COLLAPSED_FOLDERS == None:
            conf.COLLAPSED_FOLDERS = ','.join(self.get_collapsed_nodes())
        
        self.menuServers.foreach(self.menuServers.remove)
        self.treeModel.clear()
        
        iconHost = self.treeServers.render_icon("gtk-network", size=gtk.ICON_SIZE_BUTTON, detail=None)
        iconDir = self.treeServers.render_icon("gtk-directory", size=gtk.ICON_SIZE_BUTTON, detail=None)             
        
        grupos = groups.keys()
        grupos.sort(lambda x,y: cmp(y,x))
        
        for grupo in grupos:
            group = None
            path = ""
            menuNode = self.menuServers
                  
            for folder in grupo.split("/"):
                path = path + '/' + folder
                row = self.get_folder(self.treeModel, '', path)
                if row == None:
                    group = self.treeModel.prepend(group, [folder, None, iconDir])
                else:
                    group = row.iter
                
                menu = self.get_folder_menu(self.menuServers, '', path)
                if menu == None:
                    menu = gtk.ImageMenuItem(folder)
                    #menu.set_image(gtk.image_new_from_stock(gtk.STOCK_DIRECTORY, gtk.ICON_SIZE_MENU))
                    menuNode.prepend(menu)
                    menuNode = gtk.Menu()
                    menu.set_submenu(menuNode)
                    menu.show()
                else:
                    menuNode = menu
                
            groups[grupo].sort(key=operator.attrgetter('name'))
            for host in groups[grupo]:
                self.treeModel.append(group, [host.name, host, iconHost])
                mnuItem = gtk.ImageMenuItem(host.name)
                mnuItem.set_image(gtk.image_new_from_stock(gtk.STOCK_NETWORK, gtk.ICON_SIZE_MENU))
                mnuItem.show()
                mnuItem.connect("activate", lambda arg, nb, h: self.addTab(nb, h), self.nbConsole, host) 
                menuNode.append(mnuItem)
                
        self.set_collapsed_nodes()
        conf.COLLAPSED_FOLDERS = None 
开发者ID:mjun,项目名称:gnome-connection-manager,代码行数:54,代码来源:gnome_connection_manager.py


注:本文中的gtk.ImageMenuItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。