本文整理汇总了Python中gtk.MenuItem方法的典型用法代码示例。如果您正苦于以下问题:Python gtk.MenuItem方法的具体用法?Python gtk.MenuItem怎么用?Python gtk.MenuItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk
的用法示例。
在下文中一共展示了gtk.MenuItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _init_tags_menu
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import MenuItem [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()
示例2: _add_menu_item
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import MenuItem [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
示例3: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import MenuItem [as 别名]
def __init__(self):
plugin.MenuItem.__init__(self)
if not self.watches:
self.watches = {}
if not self.last_notifies:
self.last_notifies = {}
if not self.timers:
self.timers = {}
pynotify.init(APP_NAME.capitalize())
示例4: callback
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import MenuItem [as 别名]
def callback(self, menuitems, menu, terminal):
"""Add our menu items to the menu"""
if not self.watches.has_key(terminal):
item = gtk.MenuItem(_('Watch for activity'))
item.connect("activate", self.watch, terminal)
else:
item = gtk.MenuItem(_('Stop watching for activity'))
item.connect("activate", self.unwatch, terminal)
menuitems.append(item)
示例5: callback
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import MenuItem [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)
示例6: callback
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import MenuItem [as 别名]
def callback(self, menuitems, menu, terminal):
""" Add save menu item to the menu"""
vte_terminal = terminal.get_vte()
if not self.loggers.has_key(vte_terminal):
item = gtk.MenuItem(_('Start Logger'))
item.connect("activate", self.start_logger, terminal)
else:
item = gtk.MenuItem(_('Stop Logger'))
item.connect("activate", self.stop_logger, terminal)
item.set_has_tooltip(True)
item.set_tooltip_text("Saving at '" + self.loggers[vte_terminal]["filepath"] + "'")
menuitems.append(item)
示例7: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import MenuItem [as 别名]
def __init__(self):
plugin.MenuItem.__init__(self)
示例8: callback
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import MenuItem [as 别名]
def callback(self, menuitems, menu, terminal):
"""Add our menu items to the menu"""
item = gtk.MenuItem(_('Terminal screenshot'))
item.connect("activate", self.terminalshot, terminal)
menuitems.append(item)
示例9: addField
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import MenuItem [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
示例10: vwGetPopup
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import MenuItem [as 别名]
def vwGetPopup(self, textview, menu, vwfaddr=None):
"""
Over-ride this to add elements to the right click menu on click.
"""
#mn = gtk.MenuItem("Example!")
#mn.connect("activate", self.doexample)
#mn.show()
#menu.prepend(mn)
pass
示例11: populate_node_menu
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import MenuItem [as 别名]
def populate_node_menu(viz, node, menu, statistics_collector):
menu_item = gtk.MenuItem("Show Interface Statistics")
menu_item.show()
def _show_it(dummy_menu_item):
ShowInterfaceStatistics(viz, node.node_index, statistics_collector)
menu_item.connect("activate", _show_it)
menu.add(menu_item)
示例12: populate_node_menu
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import MenuItem [as 别名]
def populate_node_menu(viz, node, menu):
ns3_node = ns.network.NodeList.GetNode(node.node_index)
olsr = ns3_node.GetObject(ns.olsr.olsr.RoutingProtocol.GetTypeId())
if olsr is None:
print "No OLSR"
return
menu_item = gtk.MenuItem("Show OLSR Routing Table")
menu_item.show()
def _show_ipv4_routing_table(dummy_menu_item):
ShowOlsrRoutingTable(viz, node.node_index)
menu_item.connect("activate", _show_ipv4_routing_table)
menu.add(menu_item)
示例13: populate_node_menu
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import MenuItem [as 别名]
def populate_node_menu(viz, node, menu):
menu_item = gtk.MenuItem("Show IPv4 Routing Table")
menu_item.show()
def _show_ipv4_routing_table(dummy_menu_item):
ShowIpv4RoutingTable(viz, node.node_index)
menu_item.connect("activate", _show_ipv4_routing_table)
menu.add(menu_item)
示例14: populate_node_menu
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import MenuItem [as 别名]
def populate_node_menu(viz, node, menu):
menu_item = gtk.MenuItem("Show Last Packets")
menu_item.show()
def _show_it(dummy_menu_item):
ShowLastPackets(viz, node.node_index)
menu_item.connect("activate", _show_it)
menu.add(menu_item)
示例15: make_menu
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import MenuItem [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