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

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

项目:tools    作者:denglouping    | 项目源码 | 文件源码
def build_Menu(self):
       menu1 = gtk.Menu();
       menu2 = gtk.Menu();
       menuItem1_1 = gtk.MenuItem("1:1");
       menuItem1_2 = gtk.MenuItem("1:2");
       menuItem1_3 = gtk.MenuItem("1:3");
       menuItem2_1 = gtk.MenuItem("??");
       menuItem2_2 = gtk.MenuItem("??");
       menuItem2_3 = gtk.MenuItem("????");
       menuItem2_4 = gtk.MenuItem("?????");
       menuItem2_5 = gtk.MenuItem("????");
       menuItem2_6 = gtk.MenuItem("?????");
       menuItem2_7 = gtk.MenuItem("????")
       menu1.append(menuItem1_1)
       menu1.append(menuItem1_2)
       menu1.append(menuItem1_3)
       menu2.append(menuItem2_1)
       menu2.append(menuItem2_2)
       menu2.append(menuItem2_3)
       menu2.append(menuItem2_4)
       menu2.append(menuItem2_5)
       menu2.append(menuItem2_6)
       menu2.append(menuItem2_7)

       first_menu = gtk.MenuItem("First Menu")
       second_menu = gtk.MenuItem("?????")
       first_menu.set_submenu(menu1)
       second_menu.set_submenu(menu2)

       menuItem2_1.connect("button-press-event",self.select_Server,1);
       menuItem2_2.connect("button-press-event",self.select_Server,2);
       menuItem2_3.connect("button-press-event",self.select_Server,3);
       menuItem2_4.connect("button-press-event",self.add_Server);
       menuItem2_5.connect("button-press-event",self.create_Excel);
       menuItem2_7.connect("button-press-event",self.load_information);

       menu_bar = gtk.MenuBar()
       menu_bar.append (first_menu)
       menu_bar.append (second_menu)

       return menu_bar
项目:gui-o-matic    作者:mailpile    | 项目源码 | 文件源码
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