当前位置: 首页>>代码示例>>Python>>正文


Python GLib.PRIORITY_HIGH属性代码示例

本文整理汇总了Python中gi.repository.GLib.PRIORITY_HIGH属性的典型用法代码示例。如果您正苦于以下问题:Python GLib.PRIORITY_HIGH属性的具体用法?Python GLib.PRIORITY_HIGH怎么用?Python GLib.PRIORITY_HIGH使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在gi.repository.GLib的用法示例。


在下文中一共展示了GLib.PRIORITY_HIGH属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: copy_files

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import PRIORITY_HIGH [as 别名]
def copy_files(self, file_name, action):

        if action == 'make_backup':
            command = ['cp', '-R', self.winetricks_cache + '/' + file_name, self.winetricks_cache_backup]
        elif action == 'restore_backup':
            command = ['cp', '-R', self.winetricks_cache_backup + '/' + file_name, self.winetricks_cache]

        self.pid, stdin, stdout, stderr = GLib.spawn_async(command,
                                    flags=GLib.SpawnFlags.SEARCH_PATH|GLib.SpawnFlags.DO_NOT_REAP_CHILD,
                                    standard_output=True,
                                    standard_error=True)

        io = GLib.IOChannel(stdout)

        self.source_id_out = io.add_watch(GLib.IO_IN|GLib.IO_HUP,
                             self.watch_process,
                             'copy_files',
                             priority=GLib.PRIORITY_HIGH) 
开发者ID:yancharkin,项目名称:games_nebula,代码行数:20,代码来源:winetricks_cache_backup.py

示例2: register_signal_handlers

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import PRIORITY_HIGH [as 别名]
def register_signal_handlers(callback):
    # When using plain signal.signal to install a signal handler, the GUI will not shutdown until it receives the
    # focus again. The following logic (inspired from https://stackoverflow.com/a/26457317) fixes this
    def install_glib_handler(sig):
        unix_signal_add = None

        if hasattr(GLib, "unix_signal_add"):
            unix_signal_add = GLib.unix_signal_add
        elif hasattr(GLib, "unix_signal_add_full"):
            unix_signal_add = GLib.unix_signal_add_full

        if unix_signal_add:
            unix_signal_add(GLib.PRIORITY_HIGH, sig, callback, sig)

    def idle_handler(*args):
        GLib.idle_add(callback, *args, priority=GLib.PRIORITY_HIGH)

    for signal_code in [signal.SIGHUP, signal.SIGINT, signal.SIGTERM]:
        signal.signal(signal_code, idle_handler)
        GLib.idle_add(install_glib_handler, signal_code, priority=GLib.PRIORITY_HIGH) 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:22,代码来源:start.py

示例3: _test_multiple_undo_redo_bug_with_gui

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import PRIORITY_HIGH [as 别名]
def _test_multiple_undo_redo_bug_with_gui(gui):
    from gi.repository import GLib
    import rafcon.gui.singleton

    num_add = 10
    num_undo = 20
    num_redo = 20

    sm = StateMachine(HierarchyState())
    gui(rafcon.core.singleton.state_machine_manager.add_state_machine, sm)
    sm_m = list(rafcon.gui.singleton.state_machine_manager_model.state_machines.values())[-1]
    gui(sm_m.selection.set, [sm_m.root_state])

    main_window_controller = rafcon.gui.singleton.main_window_controller
    sm_id = sm_m.state_machine.state_machine_id
    state_machines_editor_ctrl = main_window_controller.state_machines_editor_ctrl
    gui(state_machines_editor_ctrl.get_controller(sm_id).view.get_top_widget().grab_focus)
    gui(state_machines_editor_ctrl.get_controller(sm_id).view.editor.grab_focus)
    def trigger_action_repeated(action_name, number):
        for _ in range(number):
            main_window_controller.shortcut_manager.trigger_action(action_name, None, None)
    gui(trigger_action_repeated, "add", num_add, priority=GLib.PRIORITY_HIGH)
    assert len(sm_m.history.modifications) == num_add + 1
    gui(trigger_action_repeated, "undo", num_undo, priority=GLib.PRIORITY_HIGH)
    gui.expected_warnings += max(num_undo - num_add, 0)
    gui(trigger_action_repeated, "redo", num_redo, priority=GLib.PRIORITY_HIGH)
    gui.expected_warnings += max(num_redo - min(num_add, num_undo), 0) 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:29,代码来源:test_history.py

示例4: __init__

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import PRIORITY_HIGH [as 别名]
def __init__(self, preset_select_callback):
        super().__init__()
        self.set_size_request(width=UI_SETTINGS.preset_list_minimal_width, height=-1)

        self.preset_select_callback = preset_select_callback

        self.treestore = Gtk.TreeStore(str, str, str, bool)
        self.treeview = Gtk.TreeView(
            model=self.treestore, headers_visible=False
        )
        self.treeview.connect(
            "key-press-event", self._on_keypress
        )
        self.treeview.connect(
            "row-collapsed", self._on_row_collapsed
        )
        self.treeview.connect(
            "row-expanded", self._on_row_expanded
        )
        column = Gtk.TreeViewColumn(
            cell_renderer=Gtk.CellRendererText(), markup=self.DISPLAY_NAME
        )
        self.treeview.append_column(column)
        self.load_presets()

        self.add(self.treeview)

        GLib.idle_add(
            self.focus_first_available,
            priority=GLib.PRIORITY_HIGH
        )

    ###########################################################################
    # Public interface:
    ########################################################################### 
开发者ID:themix-project,项目名称:oomox,代码行数:37,代码来源:preset_list.py

示例5: _init_signals

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import PRIORITY_HIGH [as 别名]
def _init_signals(self):
        """
        Heinous hack to properly handle signals on the mainloop. Necessary
        if we want to use the mainloop run() functionality.
        """
        def signal_action(signum):
            """
            Action to take when a signal is trapped
            """
            self.quit(signum)

        def idle_handler():
            """
            GLib idle handler to propagate signals
            """
            GLib.idle_add(signal_action, priority=GLib.PRIORITY_HIGH)

        def handler(*args):
            """
            Unix signal handler
            """
            signal_action(args[0])

        def install_glib_handler(sig):
            """
            Choose a compatible method and install the handler
            """
            unix_signal_add = None

            if hasattr(GLib, "unix_signal_add"):
                unix_signal_add = GLib.unix_signal_add
            elif hasattr(GLib, "unix_signal_add_full"):
                unix_signal_add = GLib.unix_signal_add_full

            if unix_signal_add:
                unix_signal_add(GLib.PRIORITY_HIGH, sig, handler, sig)
            else:
                print("Can't install GLib signal handler!")

        for sig in signal.SIGINT, signal.SIGTERM, signal.SIGHUP:
            signal.signal(sig, idle_handler)
            GLib.idle_add(install_glib_handler, sig, priority=GLib.PRIORITY_HIGH) 
开发者ID:openrazer,项目名称:openrazer,代码行数:44,代码来源:daemon.py


注:本文中的gi.repository.GLib.PRIORITY_HIGH属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。