Python gi.repository.Gtk 模块,Menu() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用gi.repository.Gtk.Menu()

项目:surface-orientation    作者:virtualguywithabowtie    | 项目源码 | 文件源码
def setup_menu(self,indicator):
        def add_item(item):
            item.show()
            menu.append(item)
            return item
        menu = gtk.Menu()
        toggle_button = add_item(gtk.CheckMenuItem("Lock Orentation"))
        toggle_button.connect("toggled", self.toggle, indicator)
        indicator.set_secondary_activate_target(toggle_button)
        add_item(gtk.SeparatorMenuItem())
        palm_toggle_button = add_item(gtk.CheckMenuItem("Palm Rejection"))
        palm_toggle_button.connect('toggled', self.palm_toggle, indicator)
        palm_toggle_button.set_active(True)

        add_item(gtk.MenuItem('About')).connect("activate", self.open_about_page)
        add_item(gtk.MenuItem("Exit")).connect("activate", self.quit)
        return menu
项目:YubiGuard    作者:pykong    | 项目源码 | 文件源码
def build_menu(self):
        menu = Gtk.Menu()

        item_unlock = Gtk.MenuItem('Unlock')
        item_unlock.connect('activate', self.unlock)
        menu.append(item_unlock)
        self.item_unlock = item_unlock
        self.item_unlock.set_sensitive(False)  # default state

        item_help = Gtk.MenuItem('Help')
        item_help.connect('activate', self.open_help)
        menu.append(item_help)

        separator = Gtk.SeparatorMenuItem()
        menu.append(separator)

        item_quit = Gtk.MenuItem('Quit')
        item_quit.connect('activate', self.quit)
        menu.append(item_quit)

        menu.show_all()
        return menu
项目:furi-kura    作者:benjamindean    | 项目源码 | 文件源码
def build_menu(self):
        self.INDICATOR.set_menu(Gtk.Menu())
        reddit_data = self.request.get_user_info()
        signals = {
            'inbox_handler': self.open_inbox,
            'karma_handler': self.toggle_karma_view,
            'refresh_handler': self.set_refresh_interval,
            'notifications_handler': self.notifications_handler,
            'autostart_handler': self.autostart_handler,
            'subreddit_handler': self.subreddit_chooser.show_window,
            'force_refresh_handler': self.force_refresh_handler,
            'about': self.about_handler,
            'quit': self.quit
        }

        self.builder.add_from_file(get_file('furikura/ui/menu.xml'))
        self.builder.connect_signals(signals)

        menu = self.builder.get_object('furikura_menu')
        menu.show()

        self.update_appindicator(reddit_data)
        self.run_background(self.config.get('refresh_interval'))

        self.set_radio('refresh_interval')
        self.set_radio('karma_view')
        self.set_radio('notifications')
        self.set_checkbox('autostart')

        self.INDICATOR.set_menu(menu)
项目:furi-kura    作者:benjamindean    | 项目源码 | 文件源码
def build_login_menu(self):

        def open_login(context):
            webbrowser.open(self.cfg_cls.LOGIN_URI, new=1, autoraise=True)

        login_menu = Gtk.Menu()
        item_login = Gtk.MenuItem('Login')
        item_separator = Gtk.SeparatorMenuItem()
        item_quit = Gtk.MenuItem('Quit')

        item_login.connect('activate', open_login)
        item_quit.connect('activate', self.quit)

        login_menu.append(item_login)
        login_menu.append(item_separator)
        login_menu.append(item_quit)
        login_menu.show_all()

        self.INDICATOR.set_menu(login_menu)
项目:btcwidget    作者:rafalh    | 项目源码 | 文件源码
def _create_menu(self):
        menu = Gtk.Menu()

        self._menu_item = Gtk.MenuItem("Bitcoin")
        self._menu_item.connect('activate', self._on_show_item_activate)
        menu.append(self._menu_item)

        options_menu_item = Gtk.MenuItem("Options...")
        options_menu_item.connect('activate', self._on_options_item_activate)
        menu.append(options_menu_item)

        alarm_menu_item = Gtk.MenuItem("Alarms...")
        alarm_menu_item.connect('activate', self._on_alarm_item_activate)
        menu.append(alarm_menu_item)

        quit_menu_item = Gtk.MenuItem("Quit")
        quit_menu_item.connect('activate', Gtk.main_quit)
        menu.append(quit_menu_item)

        menu.show_all()
        return menu
项目:budgie-extras    作者:UbuntuBudgie    | 项目源码 | 文件源码
def __init__(self):

        GObject.Object.__init__(self)
        settings = Gio.Settings.new("org.ubuntubudgie.plugins.budgie-extras")
        settings.bind("ws-overview-index", self,
                      'mode_index',
                      Gio.SettingsBindFlags.DEFAULT)
        # general
        self.mode = modes[self.mode_index]

        self.appbutton = Gtk.Button.new()
        self.appbutton.set_relief(Gtk.ReliefStyle.NONE)

        icon = Gtk.Image.new_from_icon_name("1-wso", Gtk.IconSize.MENU)
        self.appbutton.set_image(icon)

        self.menu = Gtk.Menu()
        self.create_menu()
        self.update = Thread(target=self.show_seconds)
        # daemonize the thread to make the indicator stopable
        self.update.setDaemon(True)
        self.update.start()
项目:emoji-keyboard    作者:OzymandiasTheGreat    | 项目源码 | 文件源码
def build_menu(self):

        menu = Gtk.Menu()
        self.show_keyboard = Gtk.ImageMenuItem('Show Keyboard')
        icon_keyboard = Gtk.Image.new_from_icon_name('keyboard', 22)
        self.show_keyboard.set_image(icon_keyboard)
        self.show_keyboard.connect('activate', self.toggle_keyboard)
        self.search = Gtk.ImageMenuItem('Search')
        icon_search = Gtk.Image.new_from_icon_name('search', 22)
        self.search.set_image(icon_search)
        self.search.connect('activate', self.toggle_search)
        self.settings = Gtk.ImageMenuItem('Settings')
        icon_settings = Gtk.Image.new_from_icon_name('configure', 22)
        self.settings.set_image(icon_settings)
        self.settings.connect('activate', self.show_settings)
        self.menu_quit = Gtk.ImageMenuItem('Quit')
        icon_quit = Gtk.Image.new_from_icon_name('application-exit', 22)
        self.menu_quit.set_image(icon_quit)
        self.menu_quit.connect('activate', self.quit)
        menu.append(self.show_keyboard)
        menu.append(self.search)
        menu.append(self.settings)
        menu.append(self.menu_quit)
        menu.show_all()
        return menu
项目:Ebook-Viewer    作者:michaldaniel    | 项目源码 | 文件源码
def __init__(self, window):
        """
        Provides
        :param window: Main application window reference, serves as communication hub
        """
        super(Gtk.HeaderBar, self).__init__()
        self.set_show_close_button(False)

        try:
            self.set_has_subtitle(True)
        except AttributeError:
            pass # Too bad?

        # Set default window title
        self.props.title = _("Preferences")
        self.__window = window
        self.__menu = Gtk.Menu()
        # Fill it with all the wigets
        self.__populate_headerbar()
项目:cryptocoin-indicator    作者:MichelMichels    | 项目源码 | 文件源码
def __init__(self):
        # Applet icon
        global indicator
        indicator = appindicator.Indicator.new(APPINDICATOR_ID, self.exchange_app.dogecoin.icon, appindicator.IndicatorCategory.SYSTEM_SERVICES)
        indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
        indicator.set_label('€ *.****', '100%')

        # Set the menu of the indicator (default: gtk.Menu())
        indicator.set_menu(self.build_menu())

        # Ctrl-C behaviour
        signal.signal(signal.SIGINT, signal.SIG_DFL)

        # Setup the refresh every 5 minutes
        gobject.timeout_add(1000*60*5, self.exchange_app.update_price, "timeout")

        # First price update within 1 second
        gobject.timeout_add(1000, self.exchange_app.first_update_price, "first_update")

        # Main loop
        gtk.main()
项目:vpn_widget    作者:deccico    | 项目源码 | 文件源码
def build_menu(self):
        menu = gtk.Menu()
        item_status = gtk.MenuItem('Connect')
        item_status.connect('activate', self.connect)
        menu.append(item_status)
        item_status = gtk.MenuItem('Disconnect')
        item_status.connect('activate', self.disconnect)
        menu.append(item_status)
        item_status = gtk.MenuItem('Display Connection Status')
        item_status.connect('activate', self.get_status)
        menu.append(item_status)
        item_quit = gtk.MenuItem('Quit')
        item_quit.connect('activate', self.quit)
        menu.append(item_quit)
        menu.show_all()
        return menu
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def create_quarter_menu(self):
        quarter_menu = Gtk.Menu()

        for key in self.quarters:
            quarter_item = Gtk.MenuItem()
            button = Gtk.CheckButton.new_with_label(self.quarters[key])
            if not self.hidden[key*2]:
                button.set_active(True)

            quarter_key = key*2
            quarter_item.connect('activate', self.toggle_quarter, quarter_key)
            quarter_item.add(button)
            quarter_menu.append(quarter_item)

        quarter_menu.show_all()
        return quarter_menu
项目:testindicator    作者:logileifs    | 项目源码 | 文件源码
def make_menu(self, event_button, event_time):
        menu = gtk.Menu()

        # show about dialog
        about = gtk.MenuItem("About")
        about.show()
        menu.append(about)
        about.connect('activate', self.show_about_dialog)

        # add quit item
        quit = gtk.MenuItem("Quit")
        quit.show()
        menu.append(quit)
        quit.connect('activate', gtk.main_quit)

        menu.popup(None, None, None, None, event_button, event_time)
项目:XFWM_theme_creator    作者:Sjc1000    | 项目源码 | 文件源码
def __init__(self):
        Gtk.ScrolledWindow.__init__(self)
        self.view = Gtk.IconView()
        self.list = Gtk.ListStore(Pixbuf, str)
        self.view.set_model(self.list)
        self.view.set_pixbuf_column(0)
        self.view.set_text_column(1)
        self.view.set_activate_on_single_click(True)
        self.view.set_item_width(100)

        self.menu = Gtk.Menu()
        copy = Gtk.MenuItem('Copy')
        copy.connect('activate', self.copy)
        paste = Gtk.MenuItem('Paste')
        paste.connect('activate', self.paste)
        self.menu.append(copy)
        self.menu.append(paste)

        self.view.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
        self.view.connect('button-press-event', self.show_menu)

        self.view.set_vexpand(True)
        self.view.set_hexpand(True)
        self.add(self.view)
        self.view.connect('item-activated', self.row_activated)
项目:poseidon    作者:sidus-dev    | 项目源码 | 文件源码
def vte_menu(widget):

    menu = Gtk.Menu()

    copy = Gtk.ImageMenuItem.new_from_stock("gtk-copy", None)
    copy.connect("activate", lambda x: widget.copy_clipboard())

    paste = Gtk.ImageMenuItem.new_from_stock("gtk-paste", None)
    paste.connect("activate", lambda x: widget.paste_clipboard())

    menu.append(copy)
    menu.append(paste)

    menu.show_all()
    menu.popup(None, None, None, None, 0, Gtk.get_current_event_time())

    return True
项目:gpt    作者:encarsia    | 项目源码 | 文件源码
def on_treeview_button_release_event(self,widget,event):
        try:
            #define context menu
            popup=Gtk.Menu()
            kd_item=Gtk.MenuItem(_("Open with Kdenlive"))
            #selected row is already caught by on_treeview_selection_changed function
            kd_item.connect("activate",self.on_open_with_kdenlive,self.sel_folder)

            #don't show menu item if there are no video files
            if self.sel_vid > 0 and cli.kd_supp is True:
                popup.append(kd_item)

            open_item=Gtk.MenuItem(_("Open folder"))
            open_item.connect("activate",self.on_open_folder,self.sel_folder)
            popup.append(open_item)
            popup.show_all()
            #only show on right click
            if event.button == 3:
                popup.popup(None,None,None,None,event.button,event.time)
                return True
        except AttributeError:
            # this error (missing variable self.sel_folder) is returned when clicking on title row
            # ignoring because there is nothing to happen on right click
            return
项目:handsup    作者:stuartlangridge    | 项目源码 | 文件源码
def main():
    global indicator, menu
    indicator = appindicator.Indicator.new(APPINDICATOR_ID, os.path.abspath('closed.svg'), appindicator.IndicatorCategory.SYSTEM_SERVICES)
    indicator.set_status(appindicator.IndicatorStatus.ACTIVE)

    pubnub = set_up_pubnub()

    menu = gtk.Menu()
    item = gtk.MenuItem('Quit')
    item.connect('activate', die, pubnub)
    menu.append(item)
    menu.show_all()

    indicator.set_menu(menu)
    indicator.set_icon(os.path.abspath("closed.svg"))

    notify.init(APPINDICATOR_ID)

    GObject.timeout_add_seconds(1, check_caps, pubnub)
    gtk.main()
项目:k380-function-keys-conf-applet    作者:cook1e-monster    | 项目源码 | 文件源码
def build_menu():
    menu = gtk.Menu()

    ### item ###
    item_on = gtk.MenuItem('On') # menu label
    item_on.connect('activate', keyboard_on) #actions
    menu.append(item_on) #add menu

    ### item ###
    item_off = gtk.MenuItem('Off') # menu label
    item_off.connect('activate', keyboard_off) #actions
    menu.append(item_off) #add menu

    ### item ###
    item_quit = gtk.MenuItem('Quit') # menu label
    item_quit.connect('activate', quit) #actions
    menu.append(item_quit) #add menu

    menu.show_all()
    return menu

### execute binary script ###
项目:dockyard    作者:maidstone-hackspace    | 项目源码 | 文件源码
def __init__(self, listbox, dialog):
        """ pass in list box to manage and connect event """
        self.logs = LogWindow()
        self.listbox = listbox
        self.listbox.connect('row-activated', self.listbox_row_activated)

        self.menu = Gtk.Menu()
        menu_item0 = Gtk.MenuItem("Terminal")
        menu_item0.connect('button_press_event', self.open_terminal)
        self.menu.append(menu_item0)

        menu_item1 = Gtk.MenuItem("Show Logs")
        self.menu.append(menu_item1)
        menu_item1.connect('button_press_event', self.show_loged)

        menu_item2 = Gtk.MenuItem("Test")
        self.menu.append(menu_item2)

        self.confirm_dialog = dialog
项目:batterym    作者:maks-a    | 项目源码 | 文件源码
def build_menu(self):
        menu = gtk.Menu()

        item = gtk.MenuItem('Battery monitor')
        item.connect('activate', self.battery_monitor)
        menu.append(item)

        item = gtk.MenuItem('Toggle theme')
        item.connect('activate', self.toggle_theme)
        menu.append(item)

        item = gtk.MenuItem('Quit')
        item.connect('activate', self.quit)
        menu.append(item)

        menu.show_all()
        return menu
项目:nba-appindicator    作者:AdeleD    | 项目源码 | 文件源码
def create_menu(self):
        menu = Gtk.Menu()

        # NBA results items
        for game in self.nba_games:
            item = Gtk.MenuItem(game['score'])
            item.connect('activate', self.on_click, game['gameinfo_url'])
            menu.append(item)

        # Quit item
        item_quit = Gtk.MenuItem('Quit')
        item_quit.connect('activate', self.on_quit)
        menu.append(item_quit)

        menu.show_all()

        self.indicator.set_menu(menu)
项目:pokemon-go-status    作者:sousatg    | 项目源码 | 文件源码
def __init__(self, indicator_id='myappindicator'):
        self.APPINDICATOR_ID = indicator_id

        self.indicator = appindicator.Indicator.new( self.APPINDICATOR_ID, 'whatever', appindicator.IndicatorCategory.SYSTEM_SERVICES)
        self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE)

        # Set Menu
        menu = gtk.Menu()
        item_quit = gtk.MenuItem('Quit')
        item_quit.connect('activate', self.quit)
        menu.show_all()
        self.indicator.set_menu( menu )


        self.update_server_status_icon()

        signal.signal( signal.SIGINT, signal.SIG_DFL )

        gtk.main()
项目:pomodoro-indicator    作者:atareao    | 项目源码 | 文件源码
def get_menu(self):
        """Create and populate the menu."""
        menu = Gtk.Menu()

        self.pomodoro_start = Gtk.MenuItem.new_with_label(_('Start'))
        self.pomodoro_start.connect('activate', self.on_pomodoro_start)
        self.pomodoro_start.show()
        menu.append(self.pomodoro_start)

        self.pomodoro_restart = Gtk.MenuItem.new_with_label(_('Re-start'))
        self.pomodoro_restart.connect('activate', self.on_pomodoro_restart)
        self.pomodoro_restart.show()
        menu.append(self.pomodoro_restart)

        separator1 = Gtk.SeparatorMenuItem()
        separator1.show()
        menu.append(separator1)
        #
        menu_preferences = Gtk.MenuItem.new_with_label(_('Preferences'))
        menu_preferences.connect('activate', self.on_preferences_item)
        menu_preferences.show()
        menu.append(menu_preferences)

        menu_help = Gtk.MenuItem.new_with_label(_('Help'))
        menu_help.set_submenu(self.get_help_menu())
        menu_help.show()
        menu.append(menu_help)
        #
        separator2 = Gtk.SeparatorMenuItem()
        separator2.show()
        menu.append(separator2)
        #
        menu_exit = Gtk.MenuItem.new_with_label(_('Exit'))
        menu_exit.connect('activate', self.on_quit_item)
        menu_exit.show()
        menu.append(menu_exit)
        #
        menu.show()
        return(menu)
项目:fux-terminal    作者:fuxprojesi    | 项目源码 | 文件源码
def on_button_press_event(wid, event):
        """
        on_button_press_event: Sa? tu?a t?kland???nda yap?lacak i?lem

        Fare'nin sa? tu?una t?kland???nda bu fonksiyon tetiklenir. Fonksiyon içinde
        T?klanan tu?un sa? tu? olup olmad??? sorgulan?r. E?er do?ru ise aç?l?r menü
        Olu?turulur. Olu?turulam menü argümanlar?na sinyaller atan?r ve gösterilir.
        """
        if event.type == Gdk.EventType.BUTTON_PRESS and event.button == 3:
           menu = Gtk.Menu()

           term = Gtk.ImageMenuItem("Terminal Aç")
           term_img = Gtk.Image()
           term_img.set_from_icon_name("utilities-terminal", Gtk.IconSize.MENU)
           term.set_image(term_img)
           term.set_always_show_image(True)

           copy = Gtk.ImageMenuItem("Kopyala")
           copy_img = Gtk.Image()
           copy_img.set_from_icon_name("edit-copy", Gtk.IconSize.MENU)
           copy.set_image(copy_img)
           copy.set_always_show_image(True)

           paste = Gtk.ImageMenuItem("Yap??t?r")
           paste_img = Gtk.Image()
           paste_img.set_from_icon_name("edit-paste", Gtk.IconSize.MENU)
           paste.set_image(paste_img)
           paste.set_always_show_image(True)

           menu.append(term)
           menu.append(Gtk.SeparatorMenuItem())
           menu.append(copy)
           menu.append(paste)

           term.connect("activate", RightClick.open_terminal)
           copy.connect("activate", RightClick.copy_text)
           paste.connect("activate", RightClick.paste_text)

           menu.show_all()
           menu.popup(None, None, None, None, event.button, event.time)
           return True
项目:scripts-systems    作者:nomad-fr    | 项目源码 | 文件源码
def main():
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    indicator = appindicator.Indicator.new(APPINDICATOR_ID, \
        os.path.abspath('/usr/share/icons/gnome/24x24/emotes/face-smile-big.png'), \
        appindicator.IndicatorCategory.SYSTEM_SERVICES)
    indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
    menu = gtk.Menu()
    indicator.set_menu(build_menu(menu))
    # GObject.timeout_add(1000, timespent, indicator, menu)
    gtk.main()
项目:budgie-extras    作者:UbuntuBudgie    | 项目源码 | 文件源码
def edit_menu2(self):
        for i in self.menu.get_children():
            self.menu.remove(i)
        for m in self.newmenu:
            ws = str(m[0] + 1)
            space = Gtk.MenuItem(ws)
            self.menu.append(space)
            if m[1]:
                # flattened submenu
                self.submenu = Gtk.Menu()
                for l in [d for d in m[1]]:
                    app = l[0]
                    wins = [[it[0], it[1]] for it in l[1]]
                    for w in wins:
                        name = self.shortname(w[0]) + "  -  " + app
                        winmention = Gtk.MenuItem(name)
                        self.submenu.append(winmention)
                        winmention.connect('activate', self.move_to, w[1])
                space.set_submenu(self.submenu)
            else:
                space.connect('activate', self.get_choice)
        # fake separator
        self.menu.append(Gtk.MenuItem(''))
        newspace = Gtk.MenuItem('+')
        newspace.connect('activate', self.add_space)
        self.menu.append(newspace)
        self.change_onthefly()
        self.menu.show_all()
项目:budgie-extras    作者:UbuntuBudgie    | 项目源码 | 文件源码
def change_onthefly(self):
        modesep = Gtk.SeparatorMenuItem()
        self.menu.add(modesep)
        mode_mention = Gtk.MenuItem("Mode")
        applet_modes = Gtk.Menu()
        active = modes.index(self.mode)
        self.mode_index = active
        self.menulist = ["      " + m for m in modes]
        self.menulist[active] = "? " + str(modes[active]) + ""
        for item in self.menulist:
            md = Gtk.MenuItem(item)
            md.connect('activate', self.set_mode, item)
            applet_modes.append(md)
        mode_mention.set_submenu(applet_modes)
        self.menu.add(mode_mention)
项目:Ebook-Viewer    作者:michaldaniel    | 项目源码 | 文件源码
def __init__(self, window):
        """
        Provides
        :param window: Main application window reference, serves as communication hub
        """
        super(Gtk.HeaderBar, self).__init__()
        self.set_show_close_button(True)
        # Set default window title
        self.props.title = _("Easy eBook Viewer")
        self.__window = window
        self.__menu = Gtk.Menu()
        # Fill it with all the wigets
        self.__populate_headerbar()
        self.job_running = False
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def __init__(self, callback):
        Gtk.Menu.__init__(self)
        for idx, pname in enumerate(soundcard.percussion_names):
            menuitem = Gtk.MenuItem(pname)
            menuitem.connect('activate', callback, idx)
            self.append(menuitem)
            menuitem.show()
        self.show()
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def popup_alsa_connection_list(self, widget):
        connection_list = soundcard.alsa_sequencer.get_connection_list()
        if connection_list:
            menu = Gtk.Menu()
            for clientid, portid, clientname, portname, labeltext in connection_list:
                item = Gtk.MenuItem(labeltext)
                menu.append(item)

                def ff(widget, clientid, portid):
                    self.g_alsa_device.set_label(widget.get_child().get_text())
                    self.m_gui_client_port = (clientid, portid)
                    self.g_alsa_radio.set_active(True)
                item.connect('activate', ff, clientid, portid)
            menu.show_all()
            menu.popup(None, None, None, None, 0, Gtk.get_current_event_time())
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def __init__(self, callback):
        Gtk.Menu.__init__(self)
        self.m_callback = callback
        for x in range(len(soundcard.instrument_names)):
            if x % 8 == 0:
                menuitem = Gtk.MenuItem(soundcard.instrument_sections[x/8])
                submenu = Gtk.Menu()
                self.append(menuitem)
                menuitem.set_submenu(submenu)
                menuitem.show()
            item = Gtk.MenuItem(soundcard.instrument_names[x])
            item.connect('activate', self.on_activate, x)
            submenu.append(item)
            item.show()
        self.show()
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def on_add(self, btn, event):
        menu = Gtk.Menu()
        item = Gtk.MenuItem(_("Add link to new page"))
        item.connect('activate', self.on_add_link_to_new_page)
        menu.append(item)
        item = Gtk.MenuItem(_("Add link to exercise"))
        item.connect('activate', self.on_add_link)
        menu.append(item)
        item = Gtk.MenuItem(_("Add link by searching for exercises"))
        item.connect('activate', self.on_add_link_by_search)
        menu.append(item)
        menu.show_all()
        menu.popup(None, None, None, None, event.button, event.time)
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def popup_folder_menu(self, event):
        # create folder; upload files; reload; share; properties
        menu = Gtk.Menu()
        self.menu = menu

        new_folder_item = Gtk.MenuItem.new_with_label(_('New Folder'))
        new_folder_item.connect('activate', self.on_new_folder_activated)
        menu.append(new_folder_item)

        sep_item = Gtk.SeparatorMenuItem()
        menu.append(sep_item)
        upload_files_item = Gtk.MenuItem.new_with_label(_('Upload Files...'))
        upload_files_item.connect('activate', self.on_upload_files_activated)
        menu.append(upload_files_item)
        upload_folders_item = Gtk.MenuItem.new_with_label(
                _('Upload Folders...'))
        upload_folders_item.connect('activate',
                                    self.on_upload_folders_activated)
        menu.append(upload_folders_item)

        sep_item = Gtk.SeparatorMenuItem()
        menu.append(sep_item)
        reload_item = Gtk.MenuItem.new_with_label(_('Reload (F5)'))
        reload_item.connect('activate', self.on_reload_activated)
        menu.append(reload_item)

        sep_item = Gtk.SeparatorMenuItem()
        menu.append(sep_item)
        props_item = Gtk.MenuItem.new_with_label(_('Properties'))
        props_item.connect('activate', self.on_props_activated)
        menu.append(props_item)

        menu.show_all()
        menu.popup(None, None, None, None, event.button, event.time)
项目:indicator-keyboard-led    作者:adrianiainlam    | 项目源码 | 文件源码
def create_menu(self, xdotool, order):
        menu = Gtk.Menu()
        xdotool = xdotool or shutil.which('xdotool')
        if xdotool and os.access(xdotool, os.X_OK) and os.path.isfile(xdotool):
            def send_keypress(menuitem, keystroke):
                subprocess.call([xdotool, 'key', keystroke])
            def new_menu_item(itemtype):
                if itemtype == 'N':
                    item = Gtk.MenuItem.new_with_label(_('Num Lock'))
                    item.connect('activate', send_keypress, 'Num_Lock')
                elif itemtype == 'C':
                    item = Gtk.MenuItem.new_with_label(_('Caps Lock'))
                    item.connect('activate', send_keypress, 'Caps_Lock')
                elif itemtype == 'S':
                    item = Gtk.MenuItem.new_with_label(_('Scroll Lock'))
                    item.connect('activate', send_keypress, 'Scroll_Lock')
                else:
                    raise ValueError('Invalid itemtype')
                return item

            for i in order:
                menu.append(new_menu_item(i))
            menu.append(Gtk.SeparatorMenuItem())

        quit_item = Gtk.MenuItem.new_with_label(_('Quit'))
        menu.append(quit_item)
        quit_item.connect('activate', Gtk.main_quit)

        self.indicator.set_menu(menu)
        menu.show_all()
项目:ircalendar-indicator    作者:733amir    | 项目源码 | 文件源码
def menu():
    m = Gtk.Menu()
    item_quit = Gtk.MenuItem('Quit')
    item_quit.connect('activate', Gtk.main_quit)
    m.append(item_quit)
    m.show_all()
    return m
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def init_main_menu(self):
        main_menu = Gtk.Menu()

        self.new_button = Gtk.MenuItem.new_with_label('New')
        self.open_button = Gtk.MenuItem.new_with_label('Open')

        self.open_stock_button = Gtk.MenuItem.new_with_label('Import Stock')

        view_button = Gtk.MenuItem.new_with_label('View')

        self.view_menu = Gtk.Menu()
        self.viewer_button = Gtk.MenuItem.new_with_label('Viewer')
        self.builder_button = Gtk.MenuItem.new_with_label('Builder')
        self.view_menu.append(self.viewer_button)
        self.view_menu.append(self.builder_button)
        self.view_menu.show_all() 

        view_button.set_submenu(self.view_menu)

        self.save_button = Gtk.MenuItem.new_with_label('Save')
        self.save_as_button = Gtk.MenuItem.new_with_label('Save As...')
        self.quit_button = Gtk.MenuItem.new_with_label('Quit')

        main_menu.append(self.new_button)
        main_menu.append(self.open_button)
        main_menu.append(self.open_stock_button) 
        main_menu.append(Gtk.SeparatorMenuItem())
        main_menu.append(view_button)
        main_menu.append(Gtk.SeparatorMenuItem())
        main_menu.append(self.save_button)
        main_menu.append(self.save_as_button)
        main_menu.append(Gtk.SeparatorMenuItem())
        main_menu.append(self.quit_button)
        main_menu.show_all()

        return main_menu
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def init_settings_menu(self):
        settings_menu = Gtk.Menu()

        self.preferences_button = Gtk.MenuItem.new_with_label('Preferences')
        settings_menu.append(self.preferences_button)

        settings_menu.show_all()
        return settings_menu
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def init_help_menu(self):
        help_menu = Gtk.Menu()

        self.app_help_button = Gtk.MenuItem.new_with_label('Help')
        self.about_button = Gtk.MenuItem.new_with_label('About')

        help_menu.append(self.about_button)
        help_menu.append(self.app_help_button)

        help_menu.show_all()
        return help_menu
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Menu.__init__(self)

        self.add_button = Gtk.MenuItem.new_with_label('Add')
        self.paste_button = Gtk.MenuItem.new_with_label('Paste')

        self.append(self.add_button)
        self.append(Gtk.SeparatorMenuItem())
        self.append(self.paste_button)

        self.show_all()
项目:nvidia-multiple-smi    作者:ClementPinard    | 项目源码 | 文件源码
def build_menu(machine):
    menu = gtk.Menu()
    host_item = gtk.MenuItem(machine['host'])
    menu.append(host_item)
    for gpu in machine['GPUs']:
        gpu['title'] = gtk.MenuItem(gpu['name'] + ', ' + '%.2f' % (gpu['memory']) + ' GB')
        gpu['title'].set_sensitive(False)
        gpu['status'] = gtk.MenuItem(str(gpu['utilization']) + '% , ' + '%.2f' % (gpu['used_mem']) + ' GB')
        menu.append(gpu['title'])
        menu.append(gpu['status'])
    menu.show_all()
    machine['menu'] = menu
项目:google-tasks-indicator    作者:atareao    | 项目源码 | 文件源码
def set_menu(self,check=False):
        #
        normal_icon = os.path.join(comun.ICONDIR,'google-tasks-indicator-%s-normal.svg'%(self.theme))
        starred_icon = os.path.join(comun.ICONDIR,'google-tasks-indicator-%s-starred.svg'%(self.theme))
        #
        self.indicator.set_icon(normal_icon)
        self.indicator.set_attention_icon(starred_icon)     
        #
        menu = Gtk.Menu()
        #
        self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
        self.menu_tasks = []
        for i in range(0,10):
            menu_note = add2menu(menu, text = '', conector_event = 'activate',conector_action = self.menu_check_item, note = googletasksapi.Task())
            menu_note.set_visible(False)
            self.menu_tasks.append(menu_note)
            #self.menu_tasks.append(add2menu(menu, text = note['title'], conector_event = 'activate',conector_action = self.menu_check_item, note = note))
        add2menu(menu)
        add2menu(menu, text = _('Add new task'), conector_event = 'activate',conector_action = self.menu_add_new_task)          
        add2menu(menu, text = _('Add new task list'), conector_event = 'activate',conector_action = self.menu_add_new_tasklist)
        add2menu(menu, text = _('Manage tasklists'), conector_event = 'activate',conector_action = self.menu_manage_tasklists)
        add2menu(menu)
        add2menu(menu, text = _('Refresh'), conector_event = 'activate',conector_action = self.menu_refresh)            
        add2menu(menu, text = _('Clear completed tasks'), conector_event = 'activate',conector_action = self.menu_clear_completed_tasks)            
        add2menu(menu, text = _('Show all tasks'), conector_event = 'activate',conector_action = self.menu_show_tasks)
        add2menu(menu, text = _('Synchronize with Google'), conector_event = 'activate',conector_action = self.sync)
        add2menu(menu)
        add2menu(menu)
        add2menu(menu, text = _('Preferences'), conector_event = 'activate',conector_action = self.menu_preferences_response)
        add2menu(menu)
        menu_help = add2menu(menu, text =_('Help'))
        menu_help.set_submenu(self.get_help_menu())
        add2menu(menu)
        add2menu(menu, text = _('Exit'), conector_event = 'activate',conector_action = self.menu_exit_response)
        menu.show()
        self.indicator.set_menu(menu)
项目:google-tasks-indicator    作者:atareao    | 项目源码 | 文件源码
def get_help_menu(self):
        help_menu =Gtk.Menu()
        #       
        add2menu(help_menu,text = _('Web...'),conector_event = 'activate',conector_action = lambda x: webbrowser.open('https://launchpad.net/google-tasks-indicator'))
        add2menu(help_menu,text = _('Get help online...'),conector_event = 'activate',conector_action = lambda x: webbrowser.open('https://answers.launchpad.net/google-tasks-indicator'))
        add2menu(help_menu,text = _('Translate this application...'),conector_event = 'activate',conector_action = lambda x: webbrowser.open('https://translations.launchpad.net/google-tasks-indicator'))
        add2menu(help_menu,text = _('Report a bug...'),conector_event = 'activate',conector_action = lambda x: webbrowser.open('https://bugs.launchpad.net/google-tasks-indicator'))
        add2menu(help_menu)
        self.menu_about = add2menu(help_menu,text = _('About'),conector_event = 'activate',conector_action = self.menu_about_response)
        #
        help_menu.show()
        #
        return help_menu
项目:google-tasks-indicator    作者:atareao    | 项目源码 | 文件源码
def create_menu(self,check=False):
        #
        normal_icon = os.path.join(comun.ICONDIR,'google-tasks-indicator-%s-normal.svg'%(self.theme))
        starred_icon = os.path.join(comun.ICONDIR,'google-tasks-indicator-%s-starred.svg'%(self.theme))
        #
        self.indicator.set_icon(normal_icon)
        self.indicator.set_attention_icon(starred_icon)     
        #
        menu = Gtk.Menu()
        #
        self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
        self.menu_tasks = []
        for i in range(10):
            menu_task = MenuNote(googletasksapi.Task())         
            menu_task.show()
            menu_task.set_visible(False)
            menu_task.connect('activate',self.menu_check_item)
            menu.append(menu_task)
            self.menu_tasks.append(menu_task)
        add2menu(menu)
        self.mant = add2menu(menu, text = _('Add new task'), conector_event = 'activate',conector_action = self.menu_add_new_task)          
        #self.mant.set_visible(self.tasklist_id is not None)        
        add2menu(menu, text = _('Add new task list'), conector_event = 'activate',conector_action = self.menu_add_new_tasklist)         
        add2menu(menu)
        add2menu(menu, text = _('Refresh'), conector_event = 'activate',conector_action = self.menu_refresh)            
        add2menu(menu, text = _('Clear completed tasks'), conector_event = 'activate',conector_action = self.menu_clear_completed_tasks)            
        add2menu(menu, text = _('Show all tasks'), conector_event = 'activate',conector_action = self.menu_show_tasks)
        add2menu(menu, text = _('Show tasks lists'), conector_event = 'activate',conector_action = self.menu_show_taskslists)
        add2menu(menu, text = _('Synchronize with Google'), conector_event = 'activate',conector_action = self.sync)
        add2menu(menu)
        add2menu(menu)
        add2menu(menu, text = _('Preferences'), conector_event = 'activate',conector_action = self.menu_preferences_response)
        add2menu(menu)
        menu_help = add2menu(menu, text =_('Help'))
        menu_help.set_submenu(self.get_help_menu())
        add2menu(menu)
        add2menu(menu, text = _('Exit'), conector_event = 'activate',conector_action = self.menu_exit_response)
        menu.show()
        self.indicator.set_menu(menu)
项目:google-tasks-indicator    作者:atareao    | 项目源码 | 文件源码
def get_help_menu(self):
        help_menu =Gtk.Menu()
        #       
        add2menu(help_menu,text = _('Web...'),conector_event = 'activate',conector_action = lambda x: webbrowser.open('https://launchpad.net/google-tasks-indicator'))
        add2menu(help_menu,text = _('Get help online...'),conector_event = 'activate',conector_action = lambda x: webbrowser.open('https://answers.launchpad.net/google-tasks-indicator'))
        add2menu(help_menu,text = _('Translate this application...'),conector_event = 'activate',conector_action = lambda x: webbrowser.open('https://translations.launchpad.net/google-tasks-indicator'))
        add2menu(help_menu,text = _('Report a bug...'),conector_event = 'activate',conector_action = lambda x: webbrowser.open('https://bugs.launchpad.net/google-tasks-indicator'))
        add2menu(help_menu)
        web = add2menu(help_menu,text = _('Homepage'),conector_event = 'activate',conector_action = lambda x: webbrowser.open('http://www.atareao.es/tag/calendar-indicator'))
        twitter = add2menu(help_menu,text = _('Follow us in Twitter'),conector_event = 'activate',conector_action = lambda x: webbrowser.open('https://twitter.com/atareao'))
        googleplus = add2menu(help_menu,text = _('Follow us in Google+'),conector_event = 'activate',conector_action = lambda x: webbrowser.open('https://plus.google.com/118214486317320563625/posts'))
        facebook = add2menu(help_menu,text = _('Follow us in Facebook'),conector_event = 'activate',conector_action = lambda x: webbrowser.open('http://www.facebook.com/elatareao'))       
        add2menu(help_menu)
        self.menu_about = add2menu(help_menu,text = _('About'),conector_event = 'activate',conector_action = self.menu_about_response)
        #       
        web.set_image(Gtk.Image.new_from_file(os.path.join(comun.SOCIALDIR,'web.svg')))
        web.set_always_show_image(True)
        twitter.set_image(Gtk.Image.new_from_file(os.path.join(comun.SOCIALDIR,'twitter.svg')))
        twitter.set_always_show_image(True)
        googleplus.set_image(Gtk.Image.new_from_file(os.path.join(comun.SOCIALDIR,'googleplus.svg')))
        googleplus.set_always_show_image(True)
        facebook.set_image(Gtk.Image.new_from_file(os.path.join(comun.SOCIALDIR,'facebook.svg')))
        facebook.set_always_show_image(True)
        #
        help_menu.show()
        return help_menu
项目:cryptobar    作者:akibabu    | 项目源码 | 文件源码
def __menu(self):
        menu = gtk.Menu()
        menu.append(self.__menu_cryptos())
        menu.append(self.__menu_fiat())
        menu.append(self.__menu_decimals())
        menu.append(self.__menu_refresh())
        menu.append(menu_quit())
        menu.show_all()
        return menu
项目:cryptobar    作者:akibabu    | 项目源码 | 文件源码
def __menu_cryptos(self):
        menu = gtk.Menu()
        option = None
        for symbol in sorted(self.symbols):
            option = gtk.RadioMenuItem(symbol, group = option)
            option.set_active(symbol == self.symbol)
            option.connect('activate', self.__set_symbol, symbol)
            menu.append(option)
        return submenu(menu, 'Set symbol')
项目:cryptobar    作者:akibabu    | 项目源码 | 文件源码
def __menu_refresh(self):
        menu = gtk.Menu()
        option = None
        for rate in REFRESH_RATES:
            option = gtk.RadioMenuItem('%sm' % rate, group = option)
            option.set_active(rate == REFRESH_RATES[0])
            option.connect('activate', self.__update_refresh_rate, rate)
            menu.append(option)
        return submenu(menu, 'Refresh rate')
项目:cryptobar    作者:akibabu    | 项目源码 | 文件源码
def __menu_fiat(self):
        menu = gtk.Menu()
        option = None
        for fiat in sorted(FIATS):
            option = gtk.RadioMenuItem(fiat, group = option)
            option.set_active(fiat == 'USD')
            option.connect('activate', self.__set_fiat, fiat)
            menu.append(option)
        return submenu(menu, 'Set fiat')
项目:cryptobar    作者:akibabu    | 项目源码 | 文件源码
def __menu_decimals(self):
        menu = gtk.Menu()
        option = None
        for i in range(11):
            option = gtk.RadioMenuItem(i, group = option)
            option.set_active(i == self.num_decimals)
            option.connect('activate', self.__set_num_decimals, i)
            menu.append(option)
        return submenu(menu, 'Set decimals')
项目:CowNewsReader    作者:blediboss    | 项目源码 | 文件源码
def build_menu(self):
        self.menu = gtk.Menu()
        self.item_main_window = gtk.MenuItem('Open Main Window')
        self.item_main_window.connect('activate', self.main_window)
        self.menu.append(self.item_main_window)
        self.menu.append(gtk.SeparatorMenuItem().new())
        self.item_quit = gtk.MenuItem('Quit')
        self.item_quit.connect('activate', self.quit)
        self.menu.append(self.item_quit)
        self.menu.show_all()
项目:ScreenRotator    作者:frecel    | 项目源码 | 文件源码
def build_menu():
    menu = Gtk.Menu()
    #brightness
    item_brightness_up = Gtk.MenuItem('Increase Brightness')
    item_brightness_up.connect('activate', increase_brightness)
    menu.append(item_brightness_up)
    item_brightness_down = Gtk.MenuItem("Decrease Brightness")
    item_brightness_down.connect('activate', decrease_brightness)
    menu.append(item_brightness_down)
    #rotate
    item_rotate = Gtk.MenuItem('Rotate')
    item_rotate.connect('activate', rotate_screen)
    menu.append(item_rotate)
    #flip
    item_flip = Gtk.MenuItem('Flip')
    item_flip.connect('activate', flip_screen)
    menu.append(item_flip)
    #seperator
    seperator = Gtk.SeparatorMenuItem()
    menu.append(seperator)
    #quit
    item_quit = Gtk.MenuItem('Quit')
    item_quit.connect('activate', quit)
    menu.append(item_quit)
    menu.show_all()
    return menu