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

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

项目: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),
        ])
项目: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)
项目:MTTT    作者:roxana-lafuente    | 项目源码 | 文件源码
def create_ui_manager(self):
        uimanager = Gtk.UIManager()
        uimanager.add_ui_from_string(UI_INFO)
        # Add the accelerator group to the toplevel window
        accelgroup = uimanager.get_accel_group()
        self.add_accel_group(accelgroup)
        return uimanager
项目:pydata_webscraping    作者:jmortega    | 项目源码 | 文件源码
def create_ui_manager(self):
        uimanager = Gtk.UIManager()

        uimanager.add_ui_from_string(UI_INFO)

        accelgroup = uimanager.get_accel_group()
        self.add_accel_group(accelgroup)
        return uimanager
项目:pydata_webscraping    作者:jmortega    | 项目源码 | 文件源码
def create_ui_manager(self):
        uimanager = Gtk.UIManager()

        uimanager.add_ui_from_string(UI_INFO)

        accelgroup = uimanager.get_accel_group()
        self.add_accel_group(accelgroup)
        return uimanager