當前位置: 首頁>>代碼示例>>Python>>正文


Python Gio.Menu方法代碼示例

本文整理匯總了Python中gi.repository.Gio.Menu方法的典型用法代碼示例。如果您正苦於以下問題:Python Gio.Menu方法的具體用法?Python Gio.Menu怎麽用?Python Gio.Menu使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gi.repository.Gio的用法示例。


在下文中一共展示了Gio.Menu方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from gi.repository import Gio [as 別名]
# 或者: from gi.repository.Gio import Menu [as 別名]
def __init__(self):
        Gtk.Application.__init__(self,
                                 application_id="com.github.bilelmoussaoui.Authenticator",
                                 flags=Gio.ApplicationFlags.FLAGS_NONE)
        GLib.set_application_name(_("Authenticator"))
        GLib.set_prgname("Authenticator")
        self.alive = True
        self._menu = Gio.Menu() 
開發者ID:bilelmoussaoui,項目名稱:Authenticator,代碼行數:10,代碼來源:application.py

示例2: __generate_menu

# 需要導入模塊: from gi.repository import Gio [as 別名]
# 或者: from gi.repository.Gio import Menu [as 別名]
def __generate_menu(self):
        """Generate application menu."""
        # Backup
        backup_content = Gio.Menu.new()
        import_menu = Gio.Menu.new()
        export_menu = Gio.Menu.new()

        import_menu.append_item(Gio.MenuItem.new(_("from a plain-text JSON file"), "app.import_json"))
        import_menu.append_item(Gio.MenuItem.new(_("from an OpenPGP-encrypted JSON file"), "app.import_pgp_json"))
        export_menu.append_item(Gio.MenuItem.new(_("in a plain-text JSON file"), "app.export_json"))
        export_menu.append_item(Gio.MenuItem.new(_("in an OpenPGP-encrypted JSON file"), "app.export_pgp_json"))

        backup_content.insert_submenu(0, _("Restore"), import_menu)
        backup_content.insert_submenu(1, _("Backup"), export_menu)

        backup_section = Gio.MenuItem.new_section(None, backup_content)
        self._menu.append_item(backup_section)

        # Main section
        main_content = Gio.Menu.new()
        # Night mode action
        main_content.append_item(Gio.MenuItem.new(_("Settings"), "app.settings"))
        main_content.append_item(Gio.MenuItem.new(_("About"), "app.about"))
        main_content.append_item(Gio.MenuItem.new(_("Quit"), "app.quit"))
        help_section = Gio.MenuItem.new_section(None, main_content)
        self._menu.append_item(help_section) 
開發者ID:bilelmoussaoui,項目名稱:Authenticator,代碼行數:28,代碼來源:application.py

示例3: __init__

# 需要導入模塊: from gi.repository import Gio [as 別名]
# 或者: from gi.repository.Gio import Menu [as 別名]
def __init__(self):
        Gtk.Application.__init__(self,
                                 application_id="com.github.bilelmoussaoui.AudioCutter",
                                 flags=Gio.ApplicationFlags.FLAGS_NONE)
        GLib.set_application_name(_("Audio Cutter"))
        GLib.set_prgname("Audio Cutter")
        self.app_menu = Gio.Menu()
        self._setup_css()
        Application.instance = self 
開發者ID:bilelmoussaoui,項目名稱:Audio-Cutter,代碼行數:11,代碼來源:application.py

示例4: _setup_app_menu

# 需要導入模塊: from gi.repository import Gio [as 別名]
# 或者: from gi.repository.Gio import Menu [as 別名]
def _setup_app_menu(self):
        """Create the appmenu."""
        # Help section
        help_content = Gio.Menu.new()
        help_content.append_item(Gio.MenuItem.new(_("Night Mode"),
                                                  "app.night_mode"))
        if Gtk.get_major_version() >= 3 and Gtk.get_minor_version() >= 20:
            help_content.append_item(Gio.MenuItem.new(_("Keyboard Shortcuts"),
                                                      "app.shortcuts"))

        help_content.append_item(Gio.MenuItem.new(_("About Audio Cutter"), "app.about"))
        help_section = Gio.MenuItem.new_section(None, help_content)
        self.app_menu.append_item(help_section)

        # Night Mode action
        is_night_mode = Settings.get_default().is_night_mode
        is_night_mode = GLib.Variant.new_boolean(is_night_mode)
        action = Gio.SimpleAction.new_stateful("night_mode", None,
                                               is_night_mode)
        action.connect("change-state", self._on_night_mode)
        self.add_action(action)

        # Shortcuts action
        if Gtk.get_major_version() >= 3 and Gtk.get_minor_version() >= 20:
            action = Gio.SimpleAction.new("shortcuts", None)
            action.connect("activate", self._on_shortcuts)
            self.add_action(action)

        # About action
        action = Gio.SimpleAction.new("about", None)
        action.connect("activate", self._on_about)
        self.add_action(action)

        # Quit action
        action = Gio.SimpleAction.new("quit", None)
        action.connect("activate", self._on_quit)
        self.add_action(action) 
開發者ID:bilelmoussaoui,項目名稱:Audio-Cutter,代碼行數:39,代碼來源:application.py

示例5: do_activate

# 需要導入模塊: from gi.repository import Gio [as 別名]
# 或者: from gi.repository.Gio import Menu [as 別名]
def do_activate(self):
        self.add_window(self.window)
        self.window.set_wmclass('HydraPaper', 'HydraPaper')
        # self.window.set_title('HydraPaper')

        appMenu = Gio.Menu()
        appMenu.append("About", "app.about")
        appMenu.append("Settings", "app.settings")
        appMenu.append("Quit", "app.quit")

        about_action = Gio.SimpleAction.new("about", None)
        about_action.connect("activate", self.on_about_activate)
        self.builder.get_object("aboutdialog").connect(
            "delete-event", lambda *_:
                self.builder.get_object("aboutdialog").hide() or True
        )
        self.add_action(about_action)

        settings_action = Gio.SimpleAction.new("settings", None)
        settings_action.connect("activate", self.on_settings_activate)
        self.builder.get_object("settingsWindow").connect(
            "delete-event", lambda *_:
                self.builder.get_object("settingsWindow").hide() or True
        )
        self.add_action(settings_action)

        quit_action = Gio.SimpleAction.new("quit", None)
        quit_action.connect("activate", self.on_quit_activate)
        self.add_action(quit_action)
        self.set_app_menu(appMenu)

        self.fill_monitors_flowbox()
        self.fill_wallpapers_folders_popover_listbox()

        self.window.show_all()

        self.refresh_wallpapers_flowbox() 
開發者ID:GabMus,項目名稱:HydraPaper,代碼行數:39,代碼來源:__main__.py

示例6: __init__

# 需要導入模塊: from gi.repository import Gio [as 別名]
# 或者: from gi.repository.Gio import Menu [as 別名]
def __init__(self, win):
        super(HeaderBar, self).__init__()
        self.win = win

        self.set_show_close_button(True)
        self.set_title('RunSQLRun')
        self.set_subtitle('Database query tool')

        self.pack_start(self._btn_from_command('app', 'neweditor'))
        self.pack_start(self._btn_from_command('editor', 'run'))

        # gears button
        menu = Gio.Menu()

        action = Gio.SimpleAction.new('manage_connections', None)
        action.connect('activate', self.on_manage_connections)
        self.win.app.add_action(action)
        menu.append('Manage connections', 'app.manage_connections')

        action = Gio.SimpleAction.new('about', None)
        action.connect('activate', self.on_show_about)
        self.win.app.add_action(action)
        menu.append('About RunSQLRun', 'app.about')

        btn = Gtk.MenuButton()
        icon = Gio.ThemedIcon(name="preferences-system-symbolic")
        image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
        btn.add(image)
        btn.set_popover(Gtk.Popover.new_from_model(btn, menu))
        self.pack_end(btn) 
開發者ID:andialbrecht,項目名稱:runsqlrun,代碼行數:32,代碼來源:headerbar.py

示例7: do_activate

# 需要導入模塊: from gi.repository import Gio [as 別名]
# 或者: from gi.repository.Gio import Menu [as 別名]
def do_activate(self):
        window = self.builder.get_object('window')
        self.add_window(window)
        window.set_wmclass('razerCommander', 'razerCommander')
        window.set_title('razerCommander')

        appMenu = Gio.Menu()
        appMenu.append("About", "app.about")
        appMenu.append("Quit", "app.quit")
        about_action = Gio.SimpleAction.new("about", None)
        about_action.connect("activate", self.on_about_activate)
        self.builder.get_object("aboutdialog").connect(
            "delete-event", lambda *_:
                self.builder.get_object("aboutdialog").hide() or True
        )
        self.add_action(about_action)
        quit_action = Gio.SimpleAction.new("quit", None)
        quit_action.connect("activate", self.on_quit_activate)
        self.add_action(quit_action)
        self.set_app_menu(appMenu)

        # initialization protocols
        self.refreshDevices()
        self.refreshProfiles()
        self.keyboardBox.hide()
        self.updateDevicesConnected()
        # Quit if we only need initialization
        if self.args.quit_after_init:
            self.quit()

        window.show_all()
        self.updateDevicesConnected()
        self.refreshFxList()
        self.keyboardBox.hide() 
開發者ID:GabMus,項目名稱:razerCommander,代碼行數:36,代碼來源:__main__.py

示例8: on_stats_button_clicked

# 需要導入模塊: from gi.repository import Gio [as 別名]
# 或者: from gi.repository.Gio import Menu [as 別名]
def on_stats_button_clicked(self, _button):
        self.stats_button.set_state_flags(Gtk.StateFlags.CHECKED, False)

        menu = Gio.Menu()
        stats = self.settings.props.settings_schema.get_key("stat-default").get_range()[1]
        for i, stat in enumerate(stats):
            menu_item = Gio.MenuItem.new(self.get_text_for_stat(i), None)
            menu_item.set_action_and_target_value("app.stat_default", GLib.Variant.new_string(stat))
            menu.append_item(menu_item)
        self.popover = Gtk.Popover.new_from_model(self.stats_button, menu)
        self.popover.connect('closed', self.on_popover_closed)
        self.popover.popup() 
開發者ID:ApostropheEditor,項目名稱:Apostrophe,代碼行數:14,代碼來源:stats_handler.py

示例9: activateCb

# 需要導入模塊: from gi.repository import Gio [as 別名]
# 或者: from gi.repository.Gio import Menu [as 別名]
def activateCb(self, app):
		window = builder.get_object("window1")
		window.set_wmclass("mLauncher", "mLauncher")
		app.add_window(window)
		appMenu=Gio.Menu()
		appMenu.append("About", "app.about")
		appMenu.append("Quit", "app.quit")
		about_action = Gio.SimpleAction.new("about", None)
		about_action.connect("activate", self.on_about_activate)
		app.add_action(about_action)
		quit_action = Gio.SimpleAction.new("quit", None)
		quit_action.connect("activate", self.on_quit_activate)
		app.add_action(quit_action)
		app.set_app_menu(appMenu)
		window.show_all() 
開發者ID:GabMus,項目名稱:mLauncher,代碼行數:17,代碼來源:main.py


注:本文中的gi.repository.Gio.Menu方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。