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


Python gtk.Menu方法代码示例

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


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

示例1: _init_tags_menu

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Menu [as 别名]
def _init_tags_menu(self):
    self._tags_menu_items = {}
    self._tags_remove_submenu_items = {}
    
    self._tags_menu_relative_position = None
    
    self._tags_menu = gtk.Menu()
    self._tags_remove_submenu = gtk.Menu()
    
    self._tags_menu.append(gtk.SeparatorMenuItem())
    
    self._menu_item_add_tag = gtk.MenuItem(_("Add New Tag..."))
    self._menu_item_add_tag.connect("activate", self._on_menu_item_add_tag_activate)
    self._tags_menu.append(self._menu_item_add_tag)
    
    self._menu_item_remove_tag = gtk.MenuItem(_("Remove Tag"))
    self._menu_item_remove_tag.set_submenu(self._tags_remove_submenu)
    self._tags_menu.append(self._menu_item_remove_tag)
    
    for tag, tag_display_name in self._available_tags_setting.default_value.items():
      self._add_tag_menu_item(tag, tag_display_name)
    
    self._tags_menu.show_all() 
开发者ID:khalim19,项目名称:gimp-plugin-export-layers,代码行数:25,代码来源:preview_name.py

示例2: _init_gui

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Menu [as 别名]
def _init_gui(self):
    if self._add_operation_text is not None:
      self._button_add = gtk.Button()
      button_hbox = gtk.HBox()
      button_hbox.set_spacing(self._ADD_BUTTON_HBOX_SPACING)
      button_hbox.pack_start(
        gtk.image_new_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_MENU),
        expand=False,
        fill=False)
      
      label_add = gtk.Label(self._add_operation_text.encode(pg.GTK_CHARACTER_ENCODING))
      label_add.set_use_underline(True)
      button_hbox.pack_start(label_add, expand=False, fill=False)
      
      self._button_add.add(button_hbox)
    else:
      self._button_add = gtk.Button(stock=gtk.STOCK_ADD)
    
    self._button_add.set_relief(gtk.RELIEF_NONE)
    self._button_add.connect("clicked", self._on_button_add_clicked)
    
    self._vbox.pack_start(self._button_add, expand=False, fill=False)
    
    self._operations_menu = gtk.Menu()
    self._init_operations_menu_popup() 
开发者ID:khalim19,项目名称:gimp-plugin-export-layers,代码行数:27,代码来源:operations.py

示例3: _add_menu_item

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Menu [as 别名]
def _add_menu_item(self, id=None, label='Menu item',
                             sensitive=False,
                             separator=False,
                             op=None, args=None,
                             **ignored_kwarg):
        if separator:
            menu_item = gtk.SeparatorMenuItem()
        else:
            menu_item = gtk.MenuItem(label)
            menu_item.set_sensitive(sensitive)
            if op:
                def activate(o, a):
                    return lambda d: self._do(o, a)
                menu_item.connect("activate", activate(op, args or []))
        menu_item.show()
        self.menu.append(menu_item)
        if id:
            self.items[id] = menu_item 
开发者ID:mailpile,项目名称:gui-o-matic,代码行数:20,代码来源:gtkbase.py

示例4: callback

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Menu [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

示例5: addField

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Menu [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

示例6: __init__

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Menu [as 别名]
def __init__(self):
        gtk.Menu.__init__(self)
        FieldAdder.__init__(self, self)
        self.set_name("vwidget_menu") 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:6,代码来源:menubuilder.py

示例7: popup_node_menu

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Menu [as 别名]
def popup_node_menu(self, node, event):
        menu = gtk.Menu()
        self.emit("populate-node-menu", node, menu)
        menu.popup(None, None, None, event.button, event.time) 
开发者ID:ntu-dsi-dcn,项目名称:ntu-dsi-dcn,代码行数:6,代码来源:core.py

示例8: make_menu

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Menu [as 别名]
def make_menu(self):
        menu = gtk.Menu()
        itemlist = [(u'Config', self.on_show),
                    ('Restart OSS-FTP', self.on_restart_ossftp),
                    (u'Quit', self.on_quit)]
        for text, callback in itemlist:
            item = gtk.MenuItem(text)
            item.connect('activate', callback)
            item.show()
            menu.append(item)
        menu.show()
        return menu 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:14,代码来源:gtk_tray.py

示例9: make_menu

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Menu [as 别名]
def make_menu(self):
        menu = gtk.Menu()
        itemlist = [(u'显示界面', self.on_show),
                    (u'项目Github页', self.show_github_page),
                    (u'退出', self.on_quit)]
        for text, callback in itemlist:
            item = gtk.MenuItem(text)
            item.connect('activate', callback)
            item.show()
            menu.append(item)
        menu.show()
        return menu 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:14,代码来源:tickeys_tray.py

示例10: on_gremlin_clicked

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Menu [as 别名]
def on_gremlin_clicked(self, widget, event, data=None):
        if event.type == gtk.gdk._2BUTTON_PRESS:
            self.clear_live_plotter()

# Settings
        if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:

            menu = gtk.Menu()

            program_alpha = gtk.CheckMenuItem("Program alpha")
            program_alpha.set_active(self.program_alpha)
            program_alpha.connect("activate", self.toggle_program_alpha)
            menu.append(program_alpha)

            show_limits = gtk.CheckMenuItem("Show limits")
            show_limits.set_active(self.show_limits)
            show_limits.connect("activate", self.toggle_show_limits)
            menu.append(show_limits)

            show_extents = gtk.CheckMenuItem("Show extents")
            show_extents.set_active(self.show_extents_option)
            show_extents.connect("activate", self.toggle_show_extents_option)
            menu.append(show_extents)

            live_plot = gtk.CheckMenuItem("Show live plot")
            live_plot.set_active(self.show_live_plot)
            live_plot.connect("activate", self.toggle_show_live_plot)
            menu.append(live_plot)

#            lathe = gtk.CheckMenuItem("Lathe mode")
#            lathe.set_active(self.lathe_option )
#            lathe.connect("activate", self.toggle_lathe_option)
#            menu.append(lathe)

            menu.popup(None, None, None, event.button, event.time)
            menu.show_all() 
开发者ID:KurtJacobson,项目名称:hazzy,代码行数:38,代码来源:hazzygremlin.py

示例11: make_menu

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Menu [as 别名]
def make_menu(self):
        menu = gtk.Menu()
        itemlist = [(u'\u663e\u793a', self.on_show),
                    (u'\u9690\u85cf', self.on_hide),
                    (u'\u505c\u6b62', self.on_stop),
                    (u'\u91cd\u65b0\u8f7d\u5165', self.on_reload),
                    (u'\u9000\u51fa', self.on_quit)]
        for text, callback in itemlist:
            item = gtk.MenuItem(text)
            item.connect('activate', callback)
            item.show()
            menu.append(item)
        menu.show()
        return menu 
开发者ID:projectarkc,项目名称:arkc-client,代码行数:16,代码来源:goagent-gtk.py

示例12: _menu_setup

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Menu [as 别名]
def _menu_setup(self):
        self.items = {}
        self.menu = gtk.Menu()
        self._create_menu_from_config() 
开发者ID:mailpile,项目名称:gui-o-matic,代码行数:6,代码来源:gtkbase.py

示例13: get_folder_menu

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Menu [as 别名]
def get_folder_menu(self, obj, folder, path):
        if not obj or not (isinstance(obj,gtk.Menu) or isinstance(obj,gtk.MenuItem)):
            return None
        for item in obj.get_children():
            if path == folder+'/'+item.get_label():
                return item.get_submenu()
            i = self.get_folder_menu(item.get_submenu(), folder+'/'+item.get_label(), path)
            if i:
                return i 
开发者ID:mjun,项目名称:gnome-connection-manager,代码行数:11,代码来源:gnome_connection_manager.py

示例14: vwGetPopup

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Menu [as 别名]
def vwGetPopup(self, textview, menu):
        va = self.selectva

        if va != None:

            pos = 0

            # Breakpoints
            bm = gtk.MenuItem("Breakpoint")
            bm.connect("activate", self.popBreakpoint, va)
            menu.insert(bm, pos)
            pos += 1

            rm = gtk.MenuItem("Run To Here")
            rm.connect("activate", self.popRunToHere, va)
            menu.insert(rm, pos)
            pos += 1

            # Watchpoints
            wmenu = gtk.Menu()
            wm = gtk.MenuItem("Watch")
            wm.set_submenu(wmenu)

            wmread = gtk.MenuItem("Reads")
            wmread.connect("activate", self.popWatchRead, va)
            wmwrite = gtk.MenuItem("Writes")
            wmwrite.connect("activate", self.popWatchWrite, va)

            wmenu.append(wmread)
            wmenu.append(wmwrite)

            menu.insert(wm, pos)
            pos += 1

            # Renderers
            rmenu = gtk.Menu()
            mn = gtk.MenuItem("Render")
            mn.set_submenu(rmenu)
            for name in self.vdbwin.db.canvas.getRendererNames():
                i = gtk.MenuItem(name)
                i.connect("activate", self.reRender, name)
                rmenu.append(i) 

            menu.insert(mn,pos)
            pos += 1

        menu.show_all() 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:49,代码来源:__init__.py

示例15: __init__

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Menu [as 别名]
def __init__(self):

            self.main_loop = gobject.MainLoop()            

            # Create a window with a horizontal scale.
            self.wnd = gtk.Window()
            self.wnd.set_default_size(640, 480)
            self.wnd.set_title('Have fun with the transparency slider')

            hscale = gtk.HScale()
            hscale.set_digits(0)
            hscale.set_increments(1, 10)
            hscale.set_range(0, 100)
            hscale.set_value(100)

            hscale.connect('value_changed', self.set_window_alpha)

            self.wnd.add(hscale)

            # Note: gtk window must be realized before installing extensions.
            self.wnd.realize()
            self.wnd.show_all()

            self.win32ext = GTKWin32Ext(self.wnd)

            self.win32ext.add_notify_icon()

            # GTK menus from the notify icon!
            menu = gtk.Menu()

            menu_item = gtk.MenuItem('Baloons!')
            menu_item.connect_object('activate', self.menu_cb, self.wnd)
            menu.append(menu_item)
                
            menu_item = gtk.MenuItem('Fadeout Window')
            menu_item.connect('activate', self.fadeoutwindow)
            menu.append(menu_item)
                
            menu_item = gtk.MenuItem('Window Disappeared?')
            menu_item.connect('activate', self.fadeinwindow)
            menu.append(menu_item)
            
            menu.show_all()
            self.win32ext.notify_icon.menu = menu

            # Set up the callback messages
            self.win32ext.message_map({
                WM_TRAYMESSAGE: self.on_notifyicon_activity
                }) 
开发者ID:ActiveState,项目名称:code,代码行数:51,代码来源:recipe-334779.py


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