當前位置: 首頁>>代碼示例>>Python>>正文


Python GLib.MainLoop方法代碼示例

本文整理匯總了Python中gi.repository.GLib.MainLoop方法的典型用法代碼示例。如果您正苦於以下問題:Python GLib.MainLoop方法的具體用法?Python GLib.MainLoop怎麽用?Python GLib.MainLoop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gi.repository.GLib的用法示例。


在下文中一共展示了GLib.MainLoop方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import MainLoop [as 別名]
def run(self):
            self.loop = GLib.MainLoop()

            if self.config.notifications:
                try:
                    notify2.init("pantalaimon", mainloop=self.loop)
                    self.notifications = True
                except dbus.DBusException:
                    logger.error(
                        "Notifications are enabled but no notification "
                        "server could be found, disabling notifications."
                    )
                    self.notifications = False

            GLib.timeout_add(100, self.message_callback)
            if not self.loop:
                return

            self.loop.run() 
開發者ID:matrix-org,項目名稱:pantalaimon,代碼行數:21,代碼來源:ui.py

示例2: main

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import MainLoop [as 別名]
def main():
    loop = asyncio.get_event_loop()
    glib_loop = GLib.MainLoop()

    try:
        panctl = PanCtl()
    except GLib.Error as e:
        print(f"Error, {e}")
        sys.exit(-1)

    fut = loop.run_in_executor(None, glib_loop.run)

    try:
        loop.run_until_complete(panctl.loop())
    except KeyboardInterrupt:
        pass

    GLib.idle_add(glib_loop.quit)
    loop.run_until_complete(fut) 
開發者ID:matrix-org,項目名稱:pantalaimon,代碼行數:21,代碼來源:panctl.py

示例3: _test_run_screen_event_loop

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import MainLoop [as 別名]
def _test_run_screen_event_loop(self):
        """
        >>> w = _refl("widget")
        >>> scr = _refl("screen")
        >>> scr.get_cols_rows_rval = (10, 5)
        >>> scr.get_input_rval = [], []
        >>> ml = MainLoop(w, screen=scr)
        >>> def stop_now(loop, data):
        ...     raise ExitMainLoop()
        >>> handle = ml.set_alarm_in(0, stop_now)
        >>> try:
        ...     ml._run_screen_event_loop()
        ... except ExitMainLoop:
        ...     pass
        screen.get_cols_rows()
        widget.render((10, 5), focus=True)
        screen.draw_screen((10, 5), None)
        screen.set_input_timeouts(0)
        screen.get_input(True)
        """ 
開發者ID:AnyMesh,項目名稱:anyMesh-Python,代碼行數:22,代碼來源:main_loop.py

示例4: __init__

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import MainLoop [as 別名]
def __init__(self, loop=None):
        self.loop = loop or GLib.MainLoop() 
開發者ID:phuhl,項目名稱:notify-send.py,代碼行數:4,代碼來源:notify_send_py.py

示例5: run

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import MainLoop [as 別名]
def run(self):
        """
        Run the Sniffer main loop.
        """
        if self.adapter is not None:
            self._log.debug("Clearing the BlueZ device registry.")
            for path, _ in get_known_devices():
                self.adapter.RemoveDevice(path)

            self._log.debug("Registering the signals InterfacesAdded and PropertiesChanged.")
            bus = pydbus.SystemBus()
            bus.subscribe(
                sender=SERVICE_NAME,
                iface=OBJECT_MANAGER_INTERFACE,
                signal="InterfacesAdded",
                signal_fired=self._cb_interfaces_added
            )
            bus.subscribe(
                sender=SERVICE_NAME,
                iface=OBJECT_MANAGER_INTERFACE,
                signal="InterfacesRemoved",
                signal_fired=self._cb_interfaces_removed
            )
            bus.subscribe(
                sender=SERVICE_NAME,
                iface=PROPERTIES_INTERFACE,
                signal="PropertiesChanged",
                arg0=DEVICE_INTERFACE,
                signal_fired=self._cb_properties_changed
            )

            self._log.debug("Running the main loop.")
            if self.output_path is not None and self.backup_interval > 0:
                GLib.timeout_add_seconds(self.backup_interval, self._cb_backup_registry)
            if self.attempt_connection:
                GLib.timeout_add_seconds(self.queueing_interval, self._cb_connect_check)
            loop = GLib.MainLoop()
            loop.run()
        else:
            raise ValueError("Sniffer.run can only be called in a context "
                             "(e.g. `with Sniffer(...) as s: s.run()`)") 
開發者ID:scipag,項目名稱:btle-sniffer,代碼行數:43,代碼來源:sniffer.py

示例6: pomodoro_daemon

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import MainLoop [as 別名]
def pomodoro_daemon():
    pomodoro = get_pomodoro_proxy()
    pomodoro.StateChanged.connect(handle_state)
    GLib.MainLoop().run() 
開發者ID:kantord,項目名稱:i3-gnome-pomodoro,代碼行數:6,代碼來源:pomodoro-client.py

示例7: assert_valid_output_file

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import MainLoop [as 別名]
def assert_valid_output_file(output_video_location):
    '''
    Given a file, validates it is a video (mp4) file
    '''
    import gi
    gi.require_version('Gst', '1.0')
    from gi.repository import Gst, GLib

    Gst.init(None)
    mainloop = GLib.MainLoop()

    # We create a pipeline so that we can read the file and check it:
    pipeline = Gst.ElementFactory.make("playbin")
    pipeline.set_property('uri','file://'+output_video_location)
    playsink = pipeline.get_by_name('playsink')
    playsink.set_property('video-sink', Gst.ElementFactory.make('fakesink'))
    pipeline.set_state(Gst.State.PAUSED)

    def after_a_second():
        assert pipeline.get_state(0).state == Gst.State.PAUSED
        element = pipeline.get_by_name('inputselector1')
        caps = element.get_static_pad('src').get_current_caps()
        assert caps.to_string() == 'audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)48000, channels=(int)2, channel-mask=(bitmask)0x0000000000000003'

        element = pipeline.get_by_name('inputselector0')
        caps = element.get_static_pad('src').get_current_caps()
        assert caps.to_string() == 'video/x-raw, format=(string)NV12, width=(int)640, height=(int)360, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)jpeg, colorimetry=(string)bt601, framerate=(fraction)30/1'

        pipeline.set_state(Gst.State.NULL)
        mainloop.quit()

    GLib.timeout_add(1000, after_a_second)
    mainloop.run() 
開發者ID:bbc,項目名稱:brave,代碼行數:35,代碼來源:test_file_output.py

示例8: _run

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import MainLoop [as 別名]
def _run(self):
        super(SignalTextInterface, self)._run()

        bus = SystemBus()

        self.signal = bus.get('org.asamk.Signal')
        self.signal.onMessageReceived = self.handle_message
        self.loop = GLib.MainLoop()

        logger.debug("Signal Interface Running")

        self.loop.run() 
開發者ID:ParadoxAlarmInterface,項目名稱:pai,代碼行數:14,代碼來源:signal.py

示例9: run

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import MainLoop [as 別名]
def run(self):
        logging.info('D-Bus process started')
        GLib.threads_init()  # allow threads in GLib
        GLib.idle_add(self._idleQueueSync)

        DBusGMainLoop(set_as_default=True)
        dbusService = SessionDBus(self.taskQueue, self.resultQueue)

        try:
            GLib.MainLoop().run()
        except KeyboardInterrupt:
            logging.debug("\nThe MainLoop will close...")
            GLib.MainLoop().quit()
        return 
開發者ID:kamwar,項目名稱:simLAB,代碼行數:16,代碼來源:dbus_ctrl.py

示例10: gobject_mainloop

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import MainLoop [as 別名]
def gobject_mainloop():
        gi.require_version('Gst', '1.0')
        from gi.repository import GLib
        GStreamerPipeline._mainloop = GLib.MainLoop()
        try:
            GStreamerPipeline._mainloop.run()
        except KeyboardInterrupt:
            pass 
開發者ID:intel,項目名稱:video-analytics-serving,代碼行數:10,代碼來源:gstreamer_pipeline.py

示例11: __init__

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import MainLoop [as 別名]
def __init__(self, *, context=None, application=None):
        self._application = application
        self._running = False
        self._argv = None

        super().__init__(context)
        if application is None:
            self._mainloop = GLib.MainLoop(self._context) 
開發者ID:pychess,項目名稱:pychess,代碼行數:10,代碼來源:glib_events.py

示例12: _test_run

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import MainLoop [as 別名]
def _test_run(self):
        """
        >>> w = _refl("widget")   # _refl prints out function calls
        >>> w.render_rval = "fake canvas"  # *_rval is used for return values
        >>> scr = _refl("screen")
        >>> scr.get_input_descriptors_rval = [42]
        >>> scr.get_cols_rows_rval = (20, 10)
        >>> scr.started = True
        >>> scr._urwid_signals = {}
        >>> evl = _refl("event_loop")
        >>> evl.enter_idle_rval = 1
        >>> evl.watch_file_rval = 2
        >>> ml = MainLoop(w, [], scr, event_loop=evl)
        >>> ml.run()    # doctest:+ELLIPSIS
        screen.set_mouse_tracking()
        screen.get_cols_rows()
        widget.render((20, 10), focus=True)
        screen.draw_screen((20, 10), 'fake canvas')
        screen.get_input_descriptors()
        event_loop.watch_file(42, <bound method ...>)
        event_loop.enter_idle(<bound method ...>)
        event_loop.run()
        event_loop.remove_enter_idle(1)
        event_loop.remove_watch_file(2)
        >>> scr.started = False
        >>> ml.run()    # doctest:+ELLIPSIS
        screen.run_wrapper(<bound method ...>)
        """ 
開發者ID:AnyMesh,項目名稱:anyMesh-Python,代碼行數:30,代碼來源:main_loop.py

示例13: _test_process_input

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import MainLoop [as 別名]
def _test_process_input(self):
        """
        >>> w = _refl("widget")
        >>> w.selectable_rval = True
        >>> scr = _refl("screen")
        >>> scr.get_cols_rows_rval = (10, 5)
        >>> ml = MainLoop(w, [], scr)
        >>> ml.process_input(['enter', ('mouse drag', 1, 14, 20)])
        screen.get_cols_rows()
        widget.selectable()
        widget.keypress((10, 5), 'enter')
        widget.mouse_event((10, 5), 'mouse drag', 1, 14, 20, focus=True)
        True
        """ 
開發者ID:AnyMesh,項目名稱:anyMesh-Python,代碼行數:16,代碼來源:main_loop.py

示例14: __init__

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import MainLoop [as 別名]
def __init__(self):
        from gi.repository import GLib
        self.GLib = GLib
        self._alarms = []
        self._watch_files = {}
        self._idle_handle = 0
        self._glib_idle_enabled = False # have we called glib.idle_add?
        self._idle_callbacks = {}
        self._loop = GLib.MainLoop()
        self._exc_info = None
        self._enable_glib_idle() 
開發者ID:AnyMesh,項目名稱:anyMesh-Python,代碼行數:13,代碼來源:main_loop.py

示例15: __init__

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import MainLoop [as 別名]
def __init__(self, bus, path):
        self.loop = GLib.MainLoop()

        interface_info = Gio.DBusNodeInfo.new_for_xml(self.__doc__).interfaces[0]

        method_outargs = {}
        method_inargs = {}
        for method in interface_info.methods:
            method_outargs[method.name] = '(' + ''.join([arg.signature for arg in method.out_args]) + ')'
            method_inargs[method.name] = tuple(arg.signature for arg in method.in_args)

        self.method_inargs = method_inargs
        self.method_outargs = method_outargs

        bus.register_object(object_path=path, interface_info=interface_info, method_call_closure=self.on_method_call) 
開發者ID:lvht,項目名稱:btk,代碼行數:17,代碼來源:dbus.py


注:本文中的gi.repository.GLib.MainLoop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。