本文整理匯總了Python中gi.repository.Atspi.event_main方法的典型用法代碼示例。如果您正苦於以下問題:Python Atspi.event_main方法的具體用法?Python Atspi.event_main怎麽用?Python Atspi.event_main使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gi.repository.Atspi
的用法示例。
在下文中一共展示了Atspi.event_main方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: start
# 需要導入模塊: from gi.repository import Atspi [as 別名]
# 或者: from gi.repository.Atspi import event_main [as 別名]
def start(self, asynchronous=False, gil=True, **kwargs):
"""
Enter the main loop to start receiving and dispatching events.
@@param asynchronous: Should event dispatch be asynchronous
(decoupled) from event receiving from the AT-SPI registry?
@@type asynchronous: boolean
@@param gil: Add an idle callback which releases the Python GIL for a few
milliseconds to allow other threads to run? Necessary if other threads
will be used in this process.
@@type gil: boolean
"""
if 'async' in kwargs:
# support previous API
asynchronous = kwargs['async']
if not self.has_implementations:
self._set_default_registry ()
self.started = True
if gil:
def releaseGIL():
try:
time.sleep(1e-2)
except KeyboardInterrupt as e:
# store the exception for later
releaseGIL.keyboard_exception = e
self.stop()
return True
# make room for an exception if one occurs during the
releaseGIL.keyboard_exception = None
i = GLib.idle_add(releaseGIL)
Atspi.event_main()
GLib.source_remove(i)
if releaseGIL.keyboard_exception is not None:
# raise an keyboard exception we may have gotten earlier
raise releaseGIL.keyboard_exception
else:
Atspi.event_main()
self.started = False
示例2: releaseGIL
# 需要導入模塊: from gi.repository import Atspi [as 別名]
# 或者: from gi.repository.Atspi import event_main [as 別名]
self._set_default_registry ()
self.started = True
if gil:
def releaseGIL():
try:
time.sleep(1e-2)
except KeyboardInterrupt, e:
# store the exception for later
releaseGIL.keyboard_exception = e
self.stop()
return True
# make room for an exception if one occurs during the
releaseGIL.keyboard_exception = None
i = GObject.idle_add(releaseGIL)
Atspi.event_main()
GObject.source_remove(i)
if releaseGIL.keyboard_exception is not None:
# raise an keyboard exception we may have gotten earlier
raise releaseGIL.keyboard_exception
else:
Atspi.event_main()
self.started = False
def stop(self, *args):
"""
Quits the main loop.
"""
if not self.has_implementations:
self._set_default_registry ()