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


Python repository.Atspi類代碼示例

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


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

示例1: deregisterKeystrokeListener

        def deregisterKeystrokeListener(self,
                                        client,
                                        key_set=[],
                                        mask=0,
                                        kind=(_KEY_PRESSED_EVENT, _KEY_RELEASED_EVENT)):
                """
                Deregisters a listener for key stroke events.

                @@param client: Callable to be invoked when the event occurs
                @@type client: callable
                @@param key_set: Set of hardware key codes to stop monitoring. Leave empty
                        to indicate all keys.
                @@type key_set: list of integer
                @@param mask: When the mask is None, the codes in the key_set will be 
                        monitored only when no modifier is held. When the mask is an 
                        integer, keys in the key_set will be monitored only when the modifiers in
                        the mask are held. When the mask is an iterable over more than one 
                        integer, keys in the key_set will be monitored when any of the modifier
                        combinations in the set are held.
                @@type mask: integer, iterable, None
                @@param kind: Kind of events to stop watching, KEY_PRESSED_EVENT or 
                        KEY_RELEASED_EVENT.
                @@type kind: list
                @@raise KeyError: When the client isn't already registered for events
                """
                if not self.has_implementations:
                        self._set_default_registry ()
                try:
                        listener = self.event_listeners[client]
                except:
                        return
                Atspi.deregister_keystroke_listener (listener, key_set, mask, kind)
開發者ID:Alberto-Beralix,項目名稱:Beralix,代碼行數:32,代碼來源:registry.py

示例2: stop

 def stop(self, *args):
         """
         Quits the main loop.
         """
         if not self.has_implementations:
                 self._set_default_registry ()
         Atspi.event_quit()
開發者ID:thnguyn2,項目名稱:ECE_527_MP,代碼行數:7,代碼來源:registry.py

示例3: _register_atspi_keystroke_listeners

    def _register_atspi_keystroke_listeners(self, register):
        if self._keystroke_listeners_registered != register:
            modifier_masks = range(16)

            if register:
                if not self._keystroke_listener:
                    self._keystroke_listener = \
                       Atspi.DeviceListener.new(self._on_atspi_keystroke, None)

                for modifier_mask in modifier_masks:
                    Atspi.register_keystroke_listener( \
                                        self._keystroke_listener,
                                        None,        # key set, None=all
                                        modifier_mask,
                                        Atspi.KeyEventType.PRESSED,
                                        Atspi.KeyListenerSyncType.SYNCHRONOUS)
            else:
                # Apparently any single deregister call will turn off
                # all the other registered modifier_masks too. Since
                # deregistering takes extremely long (~2.5s for 16 calls)
                # seize the opportunity and just pick a single arbitrary
                # mask (Quantal).
                modifier_masks = [2]

                for modifier_mask in modifier_masks:
                    Atspi.deregister_keystroke_listener(
                                        self._keystroke_listener,
                                        None, # key set, None=all
                                        modifier_mask,
                                        Atspi.KeyEventType.PRESSED)

        self._keystroke_listeners_registered = register
開發者ID:Dhiru,項目名稱:Inputability-1,代碼行數:32,代碼來源:AtspiStateTracker.py

示例4: registerKeystrokeListener

        def registerKeystrokeListener(self,
                                      client,
                                      key_set=[],
                                      mask=0,
                                      kind=(_KEY_PRESSED_EVENT, _KEY_RELEASED_EVENT),
                                      synchronous=True,
                                      preemptive=True,
                                      global_=False):
                """
                Registers a listener for key stroke events.

                @@param client: Callable to be invoked when the event occurs
                @@type client: callable
                @@param key_set: Set of hardware key codes to stop monitoring. Leave empty
                        to indicate all keys.
                @@type key_set: list of integer
                @@param mask: When the mask is None, the codes in the key_set will be 
                        monitored only when no modifier is held. When the mask is an 
                        integer, keys in the key_set will be monitored only when the modifiers in
                        the mask are held. When the mask is an iterable over more than one 
                        integer, keys in the key_set will be monitored when any of the modifier
                        combinations in the set are held.
                @@type mask: integer, iterable, None
                @@param kind: Kind of events to watch, KEY_PRESSED_EVENT or 
                        KEY_RELEASED_EVENT.
                @@type kind: list
                @@param synchronous: Should the callback notification be synchronous, giving
                        the client the chance to consume the event?
                @@type synchronous: boolean
                @@param preemptive: Should the callback be allowed to preempt / consume the
                        event?
                @@type preemptive: boolean
                @@param global_: Should callback occur even if an application not supporting
                        AT-SPI is in the foreground? (requires xevie)
                @@type global_: boolean
                """
                if not self.has_implementations:
                        self._set_default_registry ()
                try:
                        listener = self.event_listeners[client]
                except:
                        listener = self.event_listeners[client] = Atspi.DeviceListener.new(self.eventWrapper, client)
                syncFlag = self.makeSyncType(synchronous, preemptive, global_)
                try:
                        iter(mask)
                        masks = mask
                except:
                        masks = [mask]
                for m in masks:
                        Atspi.register_keystroke_listener(listener,
                                                          key_set,
                                                          m,
                                                          self.makeKind (kind),
                                                          syncFlag)
開發者ID:Alberto-Beralix,項目名稱:Beralix,代碼行數:54,代碼來源:registry.py

示例5: getLocalizedRoleName

    def getLocalizedRoleName(self, obj, role=None):
        """Returns the localized name of the given Accessible object; the name
        is suitable to be brailled.

        Arguments:
        - obj: an Accessible object
        - role: an optional pyatspi role to use instead
        """

        if _settingsManager.getSetting('brailleRolenameStyle') \
                == settings.BRAILLE_ROLENAME_STYLE_SHORT:
            objRole = role or obj.getRole()
            rv = shortRoleNames.get(objRole)
            if rv:
                return rv

        if not isinstance(role, pyatspi.Role):
            try:
                return obj.getLocalizedRoleName()
            except:
                return ''

        if not role:
            return ''

        nonlocalized = Atspi.role_get_name(role)
        atkRole = Atk.role_for_name(nonlocalized)

        return Atk.role_get_localized_name(atkRole)
開發者ID:werwoelfchen,項目名稱:orca,代碼行數:29,代碼來源:braille_generator.py

示例6: generateMouseEvent

        def generateMouseEvent(self, x, y, name):
                """
                Generates a mouse event at the given absolute x and y coordinate. The kind
                of event generated is specified by the name. For example, MOUSE_B1P 
                (button 1 press), MOUSE_REL (relative motion), MOUSE_B3D (butten 3 
                double-click).

                @@param x: Horizontal coordinate, usually left-hand oriented
                @@type x: integer
                @@param y: Vertical coordinate, usually left-hand oriented
                @@type y: integer
                @@param name: Name of the event to generate
                @@type name: string
                """
                if not self.has_implementations:
                        self._set_default_registry ()
                Atspi.generate_mouse_event (x, y, name)
開發者ID:thnguyn2,項目名稱:ECE_527_MP,代碼行數:17,代碼來源:registry.py

示例7: generateKeyboardEvent

        def generateKeyboardEvent(self, keycode, keysym, kind):
                """
                Generates a keyboard event. One of the keycode or the keysym parameters
                should be specified and the other should be None. The kind parameter is 
                required and should be one of the KEY_PRESS, KEY_RELEASE, KEY_PRESSRELEASE,
                KEY_SYM, or KEY_STRING.

                @@param keycode: Hardware keycode or None
                @@type keycode: integer
                @@param keysym: Symbolic key string or None
                @@type keysym: string
                @@param kind: Kind of event to synthesize
                @@type kind: integer
                """
                if not self.has_implementations:
                        self._set_default_registry ()
                if keysym is None:
                        keysym = ""
                Atspi.generate_keyboard_event (keycode, keysym, kind)
開發者ID:thnguyn2,項目名稱:ECE_527_MP,代碼行數:19,代碼來源:registry.py

示例8: getDesktop

        def getDesktop(self, i):
                """
                Gets a reference to the i-th desktop.

                @@param i: Which desktop to get
                @@type i: integer
                @@return: Desktop reference
                @@rtype: Accessibility.Desktop
                """
                if not self.has_implementations:
                        self._set_default_registry ()
                return Atspi.get_desktop(i)
開發者ID:thnguyn2,項目名稱:ECE_527_MP,代碼行數:12,代碼來源:registry.py

示例9: start

        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
開發者ID:GNOME,項目名稱:pyatspi2,代碼行數:40,代碼來源:registry.py

示例10: _generateRoleName

    def _generateRoleName(self, obj, **args):
        """Returns an array of sounds indicating the role of obj."""

        if not _settingsManager.getSetting('playSoundForRole'):
            return []

        role = args.get('role', obj.getRole())
        filename = Atspi.role_get_name(role).replace(' ', '_')
        result = self._convertFilenameToIcon(filename)
        if result:
            return [result]

        return []
開發者ID:GNOME,項目名稱:orca,代碼行數:13,代碼來源:sound_generator.py

示例11: absMotion

def absMotion(x_offset=0, y_offset=0):
    Atspi.generate_mouse_event(x_offset, y_offset, "abs")
    return True
開發者ID:gauravp94,項目名稱:sugar-toolkit-gtk3,代碼行數:3,代碼來源:uitree.py

示例12: releaseGIL

                        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 ()
開發者ID:thnguyn2,項目名稱:ECE_527_MP,代碼行數:31,代碼來源:registry.py

示例13: click

 def click(self, button=1, x_offset=0, y_offset=0):
     point = self._accessible.get_position(Atspi.CoordType.SCREEN)
     Atspi.generate_mouse_event(point.x+x_offset,
                                point.y+y_offset,
                                "b%sc" % button)
開發者ID:gauravp94,項目名稱:sugar-toolkit-gtk3,代碼行數:5,代碼來源:uitree.py

示例14: release

def release(button=1, x_offset=0, y_offset=0):
    Atspi.generate_mouse_event(x_offset, y_offset, "b%sr" % button)
    return True
開發者ID:gauravp94,項目名稱:sugar-toolkit-gtk3,代碼行數:3,代碼來源:uitree.py

示例15: get_root

import logging
import time

from gi.repository import Atspi
from gi.repository import GLib

Atspi.set_timeout(-1, -1)


def get_root():
    return Node(Atspi.get_desktop(0))


def _retry_find(func):
    def wrapped(*args, **kwargs):
        result = None
        n_retries = 1

        while n_retries <= 50:
            logging.info("Try %d, name=%s role_name=%s" %
                         (n_retries,
                          kwargs.get("name", None),
                          kwargs.get("role_name", None)))

            try:
                result = func(*args, **kwargs)
            except GLib.GError, e:
                # The application is not responding, try again
                if e.code == Atspi.Error.IPC:
                    continue
開發者ID:AlanJAS,項目名稱:sugar-build,代碼行數:30,代碼來源:tree.py


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