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

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

项目:ukui-menu    作者:ukui    | 项目源码 | 文件源码
def __init__( self, applet, iid ):
        self.data_path = os.path.join('/','usr','share','ukui-menu')
        self.applet = applet
        self.settings = Gio.Settings.new("org.ukui.ukui-menu")
        self.settings.connect("changed::show-category-menu",self.changeMenuState)

        self.state = self.settings.get_boolean("show-category-menu")

        self.actionNormal = Gtk.Action(name="UkuiNormalMenu", label=_("Normal Menu"), tooltip=None, stock_id="gtk-about")
        self.actionNormal.connect("activate", self.LoadNormalMenu)
        self.actionCategory = Gtk.Action(name="UkuiCategoryMenu", label=_("Category Menu"), tooltip=None, stock_id="gtk-about")
        self.actionCategory.connect("activate", self.LoadCategoryMenu)

        self.createPanelButton()
        self.applet.set_flags( UkuiPanelApplet.AppletFlags.EXPAND_MINOR )
        self.applet.connect( "button-press-event", self.showMenu )
        self.applet.connect( "enter-notify-event", self.enter_notify )
        self.applet.connect( "leave-notify-event", self.leave_notify )
        GLib.timeout_add(500, self.InitMenu )
项目: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)
项目:pydata_webscraping    作者:jmortega    | 项目源码 | 文件源码
def add_file_menu_actions(self, action_group):
        action_filemenu = Gtk.Action("FileMenu", "File", None, None)
        action_group.add_action(action_filemenu)

        action_getDataFromDataBase = Gtk.Action("getDataFromDataBase", "_obtener Datos","getDataFromDataBase", Gtk.STOCK_REFRESH)
        action_getDataFromDataBase.connect("activate", self.on_menu_getDataFromDataBase)
        action_group.add_action_with_accel(action_getDataFromDataBase, None)

        action_lanzarScrapy = Gtk.Action("lanzarScrapy", "_lanzar Scrapy","lanzarScrapy", Gtk.STOCK_EXECUTE)
        action_lanzarScrapy.connect("activate", self.on_menu_lanzarScrapy)
        action_group.add_action_with_accel(action_lanzarScrapy, None)

        action_createDataBase = Gtk.Action("createDataBase", "_crear Base Datos","createDataBase", Gtk.STOCK_EXECUTE)
        action_createDataBase.connect("activate", self.on_menu_createDataBase)
        action_group.add_action_with_accel(action_createDataBase, None)

        action_filequit = Gtk.Action("salir", None, "salir", Gtk.STOCK_QUIT)
        action_filequit.connect("activate", self.on_menu_file_quit)
        action_group.add_action(action_filequit)

    #dialogo info
项目:pydata_webscraping    作者:jmortega    | 项目源码 | 文件源码
def add_file_menu_actions(self, action_group):
        action_filemenu = Gtk.Action("FileMenu", "File", None, None)
        action_group.add_action(action_filemenu)

        action_getDataFromDataBase = Gtk.Action("getDataFromDataBase", "_obtener Datos","getDataFromDataBase", Gtk.STOCK_REFRESH)
        action_getDataFromDataBase.connect("activate", self.on_menu_getDataFromDataBase)
        action_group.add_action_with_accel(action_getDataFromDataBase, None)

        action_lanzarScrapy = Gtk.Action("lanzarScrapy", "_lanzar Scrapy","lanzarScrapy", Gtk.STOCK_EXECUTE)
        action_lanzarScrapy.connect("activate", self.on_menu_lanzarScrapy)
        action_group.add_action_with_accel(action_lanzarScrapy, None)

        action_createDataBase = Gtk.Action("createDataBase", "_crear Base Datos","createDataBase", Gtk.STOCK_EXECUTE)
        action_createDataBase.connect("activate", self.on_menu_createDataBase)
        action_group.add_action_with_accel(action_createDataBase, None)

        action_filequit = Gtk.Action("salir", None, "salir", Gtk.STOCK_QUIT)
        action_filequit.connect("activate", self.on_menu_file_quit)
        action_group.add_action(action_filequit)

    #dialogo info
项目: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)
项目:jcchess    作者:johncheetham    | 项目源码 | 文件源码
def undo_all(self, toolbutton):
        try:
            gv.ucib.stop_engine()
            gv.uciw.stop_engine()
        except:
            pass
        self.gameover = False
        while len(self.movelist) != 0:
            self.undo_move()
        self.lastmove = ""

        self.stm = self.get_side_to_move()
        gv.gui.set_side_to_move(self.stm)

        gv.board.update()
        # set move list window to initial position
        self.move_list.set_move(1)
        gv.gui.set_status_bar_msg(" ")
        if gv.show_moves == True:
            start, end =gv.gui.comment_view.get_buffer().get_bounds()
            gv.gui.comment_view.get_buffer().delete(start,end)
            gv.gui.comment_view.get_buffer().insert(start,"-")        



    #
    # called from gui.py when redo button click on toolbar (passed widget is
    # Gtk.ToolButton object) and when redo move is selected from menu
    # (or ctrl-r is pressed) (passed widget is Gtk.Action object)
    #
项目:gnome-appfolders-manager    作者:muflone    | 项目源码 | 文件源码
def __init__(self, parent, existing_folders):
        """Prepare the AppFolder creation dialog"""
        # Load the user interface
        self.ui = GtkBuilderLoader(get_ui_file('create_appfolder.ui'))
        self.ui.dialog_create_appfolder.set_titlebar(self.ui.header_bar)
        # Initialize actions
        for widget in self.ui.get_objects_by_type(Gtk.Action):
            # Connect the actions accelerators
            widget.connect_accelerator()
            # Set labels
            label = widget.get_label()
            if not label:
                label = widget.get_short_label()
            widget.set_short_label(text(label))
            widget.set_label(text(label))
        # Initialize labels
        for widget in self.ui.get_objects_by_type(Gtk.Label):
            widget.set_label(text(widget.get_label()))
        # Initialize tooltips
        for widget in self.ui.get_objects_by_type(Gtk.Button):
            action = widget.get_related_action()
            if action:
                widget.set_tooltip_text(action.get_label().replace('_', ''))
        # Set various properties
        self.ui.dialog_create_appfolder.set_transient_for(parent)
        set_style_suggested_action(self.ui.button_ok)
        self.existing_folders = existing_folders
        self.ui.button_ok.grab_default()
        self.folder_name = ''
        self.folder_title = ''
        # Connect signals from the glade file to the module functions
        self.ui.connect_signals(self)
项目:MTTT    作者:roxana-lafuente    | 项目源码 | 文件源码
def add_choices_menu_actions(self, action_group):
        self.preferences_button = Gtk.Action("VisualsMenu", "Preferences", None, None)
        action_group.add_action(self.preferences_button)
        action_visualsmenu = Gtk.Action("Visuals", "Visuals", None, None)
        action_group.add_action_with_accel(action_visualsmenu, None)
        action_group.add_radio_actions([
            ("metro", None, "metro", None, None, 1),
            ("paper", None, "paper", None, None, 2)
        ], 2, self.on_menu_choices_changed)

        lights_on_widget = Gtk.ToggleAction("lights_on_option",
                                            "Turn lights off",
                                            None, None)
        lights_on_widget.connect("toggled", self.on_menu_choices_toggled)
        action_group.add_action(lights_on_widget)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def get_test_window():
    from softwarecenter.testutils import (get_test_db,
                                          get_test_datadir,
                                          get_test_install_backend,
                                          get_test_gtk3_viewmanager,
                                          get_test_pkg_info,
                                          get_test_gtk3_icon_cache,
                                          )
    # needed because available pane will try to get it
    vm = get_test_gtk3_viewmanager()
    vm  # make pyflakes happy
    db = get_test_db()
    cache = get_test_pkg_info()
    datadir = get_test_datadir()
    icons = get_test_gtk3_icon_cache()
    backend = get_test_install_backend()

    # create global AppManager instance
    from softwarecenter.ui.gtk3.session.appmanager import ApplicationManager
    ApplicationManager(db, backend, icons)

    navhistory_back_action = Gtk.Action("navhistory_back_action", "Back",
        "Back", None)
    navhistory_forward_action = Gtk.Action("navhistory_forward_action",
        "Forward", "Forward", None)

    w = AvailablePane(cache, db, 'Ubuntu', icons, datadir,
        navhistory_back_action, navhistory_forward_action)
    w.init_view()
    w.show()

    win = Gtk.Window()
    win.connect("destroy", Gtk.main_quit)
    win.add(w)
    win.set_size_request(800, 600)
    win.show_all()

    # this is used later in tests
    win.set_data("pane", w)

    return win
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def get_test_window():
    from softwarecenter.testutils import (get_test_db,
                                          get_test_datadir,
                                          get_test_install_backend,
                                          get_test_gtk3_viewmanager,
                                          get_test_pkg_info,
                                          get_test_gtk3_icon_cache,
                                          )
    # needed because available pane will try to get it
    vm = get_test_gtk3_viewmanager()
    vm  # make pyflakes happy
    db = get_test_db()
    cache = get_test_pkg_info()
    datadir = get_test_datadir()
    icons = get_test_gtk3_icon_cache()
    backend = get_test_install_backend()

    # create global AppManager instance
    from softwarecenter.ui.gtk3.session.appmanager import ApplicationManager
    ApplicationManager(db, backend, icons)

    navhistory_back_action = Gtk.Action("navhistory_back_action", "Back",
        "Back", None)
    navhistory_forward_action = Gtk.Action("navhistory_forward_action",
        "Forward", "Forward", None)

    w = AvailablePane(cache, db, 'Ubuntu', icons, datadir,
        navhistory_back_action, navhistory_forward_action)
    w.init_view()
    w.show()

    win = Gtk.Window()
    win.connect("destroy", Gtk.main_quit)
    win.add(w)
    win.set_size_request(800, 600)
    win.show_all()

    # this is used later in tests
    win.set_data("pane", w)

    return win
项目:jcchess    作者:johncheetham    | 项目源码 | 文件源码
def goto_move(self, move_idx):
        try:
            gv.ucib.stop_engine()
            gv.uciw.stop_engine()
        except:
            pass
        self.gameover = False
        if move_idx < len(self.movelist):
            while move_idx < len(self.movelist):
                self.undo_move()
        else:
            while move_idx > len(self.movelist):
                self.redo_move()

        self.stm = self.get_side_to_move()
        gv.gui.set_side_to_move(self.stm)

        gv.board.update()
        # gv.gui.set_status_bar_msg(" ")
        move = None
        try:
            move = self.movelist[len(self.movelist) - 1]
            self.lastmove = move
            # print "move ",move
        except IndexError:
            pass

        if move is not None:
            gv.gui.set_status_bar_msg(self.convert_move(move_idx)+move)
            if gv.show_moves == True:
               nmoves = len(self.movelist)
               path =(nmoves-1,)
               sel = gv.gui.move_view.get_selection()
               sel.select_path(path)  # path has to be set to nmoves-1 to hit the right selection
               self.move_list.set_move(nmoves)
               #print(nmoves, "goto move")             
        else:
            gv.gui.set_status_bar_msg(" ")

    #
    # called from gui.py when undo button click on toolbar (passed widget is
    # Gtk.ToolButton object) and when undo move is selected from menu
    # (or ctrl-u is pressed) (passed widget is Gtk.Action object)
    #