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

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

项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def __init__(self, filename=None):
        self.m_instance_number = EditorDialogBase.instance_counter
        EditorDialogBase.instance_counter += 1
        self.m_filename = filename
        self.m_savetime = time.time()
        self.connect('delete_event', self.on_delete_event)
        self.g_ui_manager = Gtk.UIManager()
        accelgroup = self.g_ui_manager.get_accel_group()
        self.add_accel_group(accelgroup)

        self.g_actiongroup = Gtk.ActionGroup('')
        self.g_actiongroup.add_actions([
         ('Close', Gtk.STOCK_CLOSE, None, None, None, self.close_window),
         ('Save', Gtk.STOCK_SAVE, None, None, None, self.on_save),
         ('SaveAs', Gtk.STOCK_SAVE_AS, None, None, None, self.on_save_as),
         ('New', Gtk.STOCK_NEW, None, None, None, self.new_file),
         ('Open', Gtk.STOCK_OPEN, None, None, None, self.on_open),
         ('Help', Gtk.STOCK_HELP, None, None, None, self.on_show_help),
        ])
项目:ukui-menu    作者:ukui    | 项目源码 | 文件源码
def create_menu(self):
        action_group = Gtk.ActionGroup(name="context-menu")
        action_group.add_action(self.actionNormal)
        action_group.add_action(self.actionCategory)
        if self.state:
            self.actionNormal.set_visible(True)
            self.actionCategory.set_visible(False)
        else:
            self.actionNormal.set_visible(False)
            self.actionCategory.set_visible(True)
        action = Gtk.Action(name="UkuiMenuReload", label=_("Reload plugins"), tooltip=None, stock_id="gtk-refresh")
        action.connect("activate", self.mainwin.RegenPlugins)
        action_group.add_action(action)
        action = Gtk.Action(name="UkuiMenuAbout", label=_("About"), tooltip=None, stock_id="gtk-about")
        action.connect("activate", self.showAboutDialog)
        action_group.add_action(action)
        action_group.set_translation_domain ("ukui-menu")

        xml = os.path.join( self.data_path, "popup.xml" )
        self.applet.setup_menu_from_file(xml, action_group)
项目:mate-menu    作者:ubuntu-mate    | 项目源码 | 文件源码
def create_menu(self):
        action_group = Gtk.ActionGroup(name="context-menu")
        action = Gtk.Action(name="MateMenuPrefs", label=_("Preferences"), tooltip=None, icon_name="preferences-system")
        action.connect("activate", self.showPreferences)
        action_group.add_action(action)
        action = Gtk.Action(name="MateMenuEdit", label=_("Edit menu"), tooltip=None, stock_id=Gtk.STOCK_EDIT)
        action.connect("activate", self.showMenuEditor)
        action_group.add_action(action)
        action = Gtk.Action(name="MateMenuReload", label=_("Reload plugins"), tooltip=None, icon_name="view-refresh")
        action.connect("activate", self.mainwin.RegenPlugins)
        action_group.add_action(action)
        action = Gtk.Action(name="MateMenuAbout", label=_("About"), tooltip=None, icon_name="help-about")
        action.connect("activate", self.showAboutDialog)
        action_group.add_action(action)
        action_group.set_translation_domain ("mate-menu")

        xml = os.path.join( self.data_path, "popup.xml" )
        self.applet.setup_menu_from_file(xml, action_group)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def create_menu_and_toolbar(self):
        self.window_ag = Gtk.ActionGroup('WindowActions')
        self.lessonfile_ag = Gtk.ActionGroup('LessonfileActions')

        self.window_ag.add_actions(fix_actions(window_actions, self))
        self.lessonfile_ag.add_actions(fix_actions(lessonfile_actions, self))
        self.ui = Gtk.UIManager()
        self.ui.insert_action_group(self.window_ag, 0)
        self.ui.insert_action_group(self.lessonfile_ag, 1)
        self.ui.add_ui_from_string(ui_string)
        self.add_accel_group(self.ui.get_accel_group())
        self.toplevel_vbox.pack_start(self.ui.get_widget('/Menubar', True, True, 0), False)
        self.ui.get_widget('/Toolbar').set_style(Gtk.TOOLBAR_ICONS)
        self.toplevel_vbox.pack_start(self.ui.get_widget('/Toolbar', True, True, 0), False)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def __init__(self, options, datadir):
        Gtk.Window.__init__(self, Gtk.WindowType.TOPLEVEL)
        self._vbox = Gtk.VBox()
        self._vbox.show()
        self.add(self._vbox)
        stock.SolfegeIconFactory(self, datadir)
        Gtk.Settings.get_default().set_property('gtk-button-images', True)
        cfg.ConfigUtils.__dict__['__init__'](self, 'mainwin')
        self.set_resizable(self.get_bool('gui/mainwin_user_resizeable'))
        self.add_watch('gui/mainwin_user_resizeable', lambda s: self.set_resizable(self.get_bool('gui/mainwin_user_resizeable')))
        self.connect('delete-event', self.quit_program)
        self.connect('key_press_event', self.on_key_press_event)
        self.g_about_window = None
        self.m_exercise = None
        self.m_viewer = None
        self.box_dict = {}
        self.g_config_window = None
        self.g_path_info_dlg = None
        self.g_musicviewer_window = None
        self.m_history = []
        self.g_ui_manager = Gtk.UIManager()
        self.m_action_groups = {
            'Exit': Gtk.ActionGroup('Exit'),
            'NotExit': Gtk.ActionGroup('NotExit'),
        }
        for a in self.m_action_groups.values():
            self.g_ui_manager.insert_action_group(a, 1)
        self.setup_menu()
        self.main_box = Gtk.VBox()
        self.main_box.show()
        self._vbox.pack_start(self.main_box, True, True, 0)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def __init__(self):
        GObject.GObject.__init__(self)

        # XDotWidget
        xdotwidget = self.xdotwidget = xdot.DotWidget()
        # Toolbar
        uimanager = Gtk.UIManager()
        actiongroup = Gtk.ActionGroup('Actions')
        actiongroup.add_actions((
            ('ZoomIn', Gtk.STOCK_ZOOM_IN, None, None, None, self.xdotwidget.on_zoom_in),
            ('ZoomOut', Gtk.STOCK_ZOOM_OUT, None, None, None, self.xdotwidget.on_zoom_out),
            ('ZoomFit', Gtk.STOCK_ZOOM_FIT, None, None, None, self.xdotwidget.on_zoom_fit),
            ('Zoom100', Gtk.STOCK_ZOOM_100, None, None, None, self.xdotwidget.on_zoom_100),
        ))
        uimanager.insert_action_group(actiongroup, 0)
        uimanager.add_ui_from_string(self.ui)
        toolbar = uimanager.get_widget('/ToolBar')
        toolbar.set_icon_size(Gtk.IconSize.SMALL_TOOLBAR)
        toolbar.set_style(Gtk.ToolbarStyle.ICONS)
        toolbar.set_show_arrow(False)
        label = self.label = Gtk.Label()
        hbox = Gtk.HBox(False, 5)
        hbox.pack_start(toolbar, False, True, 0)
        hbox.pack_start(label, False, True, 0)
        self.pack_start(hbox, False, True, 0)
        self.pack_start(xdotwidget, True, True, 0)