当前位置: 首页>>代码示例>>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;未经允许,请勿转载。