Python gtk.MenuItem() Examples

The following are 30 code examples of gtk.MenuItem(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gtk , or try the search function .
Example #1
Source File: gtkbase.py    From gui-o-matic with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 
Example #2
Source File: preview_name.py    From gimp-plugin-export-layers with GNU General Public License v3.0 6 votes vote down vote up
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() 
Example #3
Source File: olsr.py    From ns3-ecn-sharp with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #4
Source File: olsr.py    From royal-chaos with MIT License 5 votes vote down vote up
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) 
Example #5
Source File: interface_statistics.py    From Tocino with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #6
Source File: show_last_packets.py    From ns3-802.11ad with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #7
Source File: ipv4_routing_table.py    From ns3-802.11ad with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #8
Source File: preview_name.py    From gimp-plugin-export-layers with GNU General Public License v3.0 5 votes vote down vote up
def _add_remove_tag_menu_item(self, tag, tag_display_name):
    self._tags_remove_submenu_items[tag] = gtk.MenuItem(tag_display_name)
    self._tags_remove_submenu_items[tag].connect(
      "activate", self._on_tags_remove_submenu_item_activate, tag)
    self._tags_remove_submenu_items[tag].show()
    self._tags_remove_submenu.prepend(self._tags_remove_submenu_items[tag]) 
Example #9
Source File: operations.py    From gimp-plugin-export-layers with GNU General Public License v3.0 5 votes vote down vote up
def _add_operation_to_menu_popup(self, operation_dict):
    menu_item = gtk.MenuItem(
      label=operation_dict["display_name"].encode(pg.GTK_CHARACTER_ENCODING),
      use_underline=False)
    menu_item.connect("activate", self._on_operations_menu_item_activate, operation_dict)
    self._operations_menu.append(menu_item) 
Example #10
Source File: operations.py    From gimp-plugin-export-layers with GNU General Public License v3.0 5 votes vote down vote up
def _add_add_custom_operation_to_menu_popup(self):
    menu_item = gtk.MenuItem(label=self._add_custom_operation_text, use_underline=False)
    menu_item.connect("activate", self._on_add_custom_operation_menu_item_activate)
    self._operations_menu.append(menu_item) 
Example #11
Source File: goagent-gtk.py    From arkc-client with GNU General Public License v2.0 5 votes vote down vote up
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 
Example #12
Source File: gtkbase.py    From gui-o-matic with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _main_window_indicator(self, menu_container, icon_container):
        if not self._HAVE_INDICATOR:
            menubar = gtk.MenuBar()
            im = gtk.MenuItem(self.config.get('app_name', 'GUI-o-Matic'))
            im.set_submenu(self.menu)
            menubar.append(im)
            menu_container.pack_start(menubar, False, True)

            icon = gtk.Image()
            icon_container.pack_start(icon, False, True)
            self.main_window['indicator_icon'] = icon 
Example #13
Source File: gnome_connection_manager.py    From gnome-connection-manager with GNU General Public License v3.0 5 votes vote down vote up
def createMenuItem(self, shortcut, label):
        menuItem = gtk.MenuItem('')
        menuItem.get_child().set_markup("<span color='blue'  size='x-small'>[%s]</span> %s" % (shortcut, label))
        menuItem.show()
        return menuItem 
Example #14
Source File: gnome_connection_manager.py    From gnome-connection-manager with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #15
Source File: show_last_packets.py    From Tocino with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #16
Source File: show_last_packets.py    From ns3-ecn-sharp with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #17
Source File: ipv4_routing_table.py    From ns3-ecn-sharp with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #18
Source File: olsr.py    From ns3-802.11ad with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #19
Source File: interface_statistics.py    From ns3-ecn-sharp with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #20
Source File: show_last_packets.py    From CRE-NS3 with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #21
Source File: ipv4_routing_table.py    From CRE-NS3 with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #22
Source File: olsr.py    From CRE-NS3 with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #23
Source File: interface_statistics.py    From CRE-NS3 with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #24
Source File: tickeys_tray.py    From Tickeys-linux with MIT License 5 votes vote down vote up
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 
Example #25
Source File: show_last_packets.py    From ns-3-dev-git with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #26
Source File: ipv4_routing_table.py    From ns-3-dev-git with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #27
Source File: olsr.py    From ns-3-dev-git with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #28
Source File: interface_statistics.py    From ns-3-dev-git with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #29
Source File: show_last_packets.py    From royal-chaos with MIT License 5 votes vote down vote up
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) 
Example #30
Source File: ipv4_routing_table.py    From royal-chaos with MIT License 5 votes vote down vote up
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)