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


Python Xlib.X屬性代碼示例

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


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

示例1: _shift_mask

# 需要導入模塊: import Xlib [as 別名]
# 或者: from Xlib import X [as 別名]
def _shift_mask(self, modifiers):
        """The *X* modifier mask to apply for a set of modifiers.

        :param set modifiers: A set of active modifiers for which to get the
            shift mask.
        """
        return (
            0
            | (self.ALT_MASK
               if Key.alt in modifiers else 0)

            | (self.ALT_GR_MASK
               if Key.alt_gr in modifiers else 0)

            | (self.CTRL_MASK
               if Key.ctrl in modifiers else 0)

            | (self.SHIFT_MASK
               if Key.shift in modifiers else 0)) 
開發者ID:mass-immersion-approach,項目名稱:MIA-Dictionary-Addon,代碼行數:21,代碼來源:_xorg.py

示例2: _keycode_to_keysym

# 需要導入模塊: import Xlib [as 別名]
# 或者: from Xlib import X [as 別名]
def _keycode_to_keysym(self, display, keycode, index):
        """Converts a keycode and shift state index to a keysym.

        This method uses a simplified version of the *X* convention to locate
        the correct keysym in the display table: since this method is only used
        to locate special keys, alphanumeric keys are not treated specially.

        :param display: The current *X* display.

        :param keycode: The keycode.

        :param index: The shift state index.

        :return: a keysym
        """
        keysym = display.keycode_to_keysym(keycode, index)
        if keysym:
            return keysym
        elif index & 0x2:
            return self._keycode_to_keysym(display, keycode, index & ~0x2)
        elif index & 0x1:
            return self._keycode_to_keysym(display, keycode, index & ~0x1)
        else:
            return 0 
開發者ID:mass-immersion-approach,項目名稱:MIA-Dictionary-Addon,代碼行數:26,代碼來源:_xorg.py

示例3: _send_key

# 需要導入模塊: import Xlib [as 別名]
# 或者: from Xlib import X [as 別名]
def _send_key(self, event, keycode, shift_state):
        """Sends a single keyboard event.

        :param event: The *X* keyboard event.

        :param int keycode: The calculated keycode.

        :param int shift_state: The shift state. The actual value used is
            :attr:`shift_state` or'd with this value.
        """
        with display_manager(self._display) as dm, self.modifiers as modifiers:
            # Under certain cimcumstances, such as when running under Xephyr,
            # the value returned by dm.get_input_focus is an int
            window = dm.get_input_focus().focus
            send_event = getattr(
                window,
                'send_event',
                lambda event: dm.send_event(window, event))
            send_event(event(
                detail=keycode,
                state=shift_state | self._shift_mask(modifiers),
                time=0,
                root=dm.screen().root,
                window=window,
                same_screen=0,
                child=Xlib.X.NONE,
                root_x=0, root_y=0, event_x=0, event_y=0)) 
開發者ID:mass-immersion-approach,項目名稱:MIA-Dictionary-Addon,代碼行數:29,代碼來源:_xorg.py

示例4: _handle

# 需要導入模塊: import Xlib [as 別名]
# 或者: from Xlib import X [as 別名]
def _handle(self, display, event):
        # Convert the event to a KeyCode; this may fail, and in that case we
        # pass None
        try:
            key = self._event_to_key(display, event)
        except IndexError:
            key = None

        if event.type == Xlib.X.KeyPress:
            self.on_press(key)

        elif event.type == Xlib.X.KeyRelease:
            self.on_release(key) 
開發者ID:mass-immersion-approach,項目名稱:MIA-Dictionary-Addon,代碼行數:15,代碼來源:_xorg.py

示例5: _suppress_start

# 需要導入模塊: import Xlib [as 別名]
# 或者: from Xlib import X [as 別名]
def _suppress_start(self, display):
        display.screen().root.grab_keyboard(
            self._event_mask, Xlib.X.GrabModeAsync, Xlib.X.GrabModeAsync,
            Xlib.X.CurrentTime) 
開發者ID:mass-immersion-approach,項目名稱:MIA-Dictionary-Addon,代碼行數:6,代碼來源:_xorg.py

示例6: set_state

# 需要導入模塊: import Xlib [as 別名]
# 或者: from Xlib import X [as 別名]
def set_state(self, state=NORMAL, size=(-1, -1), pos=(-1, -1), update=True):
        """Set wheter the window is maximized or not, or minimized or full screen.
        If no argument is given, assume the state will be windowed and not maximized.
        If arguments are given, only the first is relevant. The other ones are ignored.

        ** Only maximized and normal states are implemented for now. **

        :state: valid arguments:
        'minimized', MINIMIZED, 0.
        'normal', NORMAL, 1: windowed, not maximized.
        'maximized', MAXIMIZED, 2.
        'fullscreen, FULLSCREEN, 3.

        :size: list, tuple: the new size; if (-1, -1) self.get_size() is used.
               If one element is -1 it is replaced by the corresponding valur from self.get_size().
        :pos: list, tuple: the new position; if (-1, -1), self.get_position is used.
              If one element is -1 it is replaced by the corresponding valur from self.get_position().
        :update: bool: whether to call the internal flush method."""
        if state not in (0, MINIMIZED, 'minimized', 1, NORMAL, 'normal', 2, MAXIMIZED, 'maximized', 3, FULLSCREEN, 'fullscreen'):
            # Raise a value error.
            raise ValueError, "Invalid state argument: %s is not a correct value" % state
        if type(size) not in (list, tuple):
            raise TypeError, "Invalid size argument: %s is not a list or a tuple."
        if type(pos) not in (list, tuple):
            raise TypeError, "Invalid pos argument: %s is not a list or a tuple."

        if state in (1, NORMAL, 'normal'):
            size = list(size)
            sz = self.get_size()
            if size[0] == -1:
                size[0] = sz[0]
            if size[1] == -1:
                size[1] = sz[1]
            pos = list(pos)
            ps = self.get_position()
            if pos[0] == -1:
                pos[0] = ps[0]
            if pos[1] == -1:
                pos[1] = ps[1]
            self.set_mode(size, self.mode)
            self.set_position(pos)
        elif state in (0, MINIMIZED, 'minimized'):
            pass
        elif state in (2, MAXIMIZED, 'maximized'):
            data = [1, self.display.intern_atom("_NET_WM_STATE_MAXIMIZED_VERT", False), self.display.intern_atom("_NET_WM_STATE_MAXIMIZED_HORZ", False)]
            data = (data + ([0] * (5 - len(data))))[:5]
            if DEBUG_WM:
                print self.stateHandler.get_wm_state()
                print "creating event", Xlib.protocol.event.ClientMessage
                print dir(self.stateHandler)
            x_event = Xlib.protocol.event.ClientMessage(window=self.stateHandler, client_type=self.display.intern_atom("_NET_WM_STATE", False), data=(32, (data)))
            if DEBUG_WM:
                print "sending event"
            self.display.screen().root.send_event(x_event, event_mask=Xlib.X.SubstructureRedirectMask)

            if DEBUG_WM:
                print self.stateHandler.get_wm_state()
        elif state in (3, FULLSCREEN, 'fullscreen'):
            pass
        if update:
            self.flush() 
開發者ID:mcgreentn,項目名稱:GDMC,代碼行數:63,代碼來源:mcplatform.py

示例7: _event_to_key

# 需要導入模塊: import Xlib [as 別名]
# 或者: from Xlib import X [as 別名]
def _event_to_key(self, display, event):
        """Converts an *X* event to a :class:`KeyCode`.

        :param display: The current *X* display.

        :param event: The event to convert.

        :return: a :class:`pynput.keyboard.KeyCode`

        :raises IndexError: if the key code is invalid
        """
        keycode = event.detail
        index = shift_to_index(display, event.state)

        # First try special keys...
        keysym = self._keycode_to_keysym(display, keycode, index)
        if keysym in self._SPECIAL_KEYS:
            return self._SPECIAL_KEYS[keysym]
        elif keysym in self._KEYPAD_KEYS:
            # We must recalculate the index if numlock is active; index 1 is the
            # one to use
            try:
                return self._KEYPAD_KEYS[
                    self._keycode_to_keysym(
                        display,
                        keycode,
                        bool(event.state & numlock_mask(display)))]
            except KeyError:
                # Since we recalculated the key, this may happen
                pass

        # ...then try characters...
        name = KEYSYMS.get(keysym, None)
        if name is not None and name in SYMBOLS:
            char = SYMBOLS[name][1].upper() if index & 1 else SYMBOLS[name][1]
            if char in DEAD_KEYS:
                return KeyCode.from_dead(DEAD_KEYS[char], vk=keysym)
            else:
                return KeyCode.from_char(char, vk=keysym)

        # ...and fall back on a virtual key code
        return KeyCode.from_vk(keysym) 
開發者ID:mass-immersion-approach,項目名稱:MIA-Dictionary-Addon,代碼行數:44,代碼來源:_xorg.py

示例8: set_state

# 需要導入模塊: import Xlib [as 別名]
# 或者: from Xlib import X [as 別名]
def set_state(self, state=NORMAL, size=(-1, -1), pos=(-1, -1), update=True):
        """Set whether the window is maximized or not, or minimized or full screen.
        If no argument is given, assume the state will be windowed and not maximized.
        If arguments are given, only the first is relevant. The other ones are ignored.

        ** Only maximized and normal states are implemented for now. **

        :state: valid arguments:
        'minimized', MINIMIZED, 0.
        'normal', NORMAL, 1: windowed, not maximized.
        'maximized', MAXIMIZED, 2.
        'fullscreen, FULLSCREEN, 3.

        :size: list, tuple: the new size; if (-1, -1) self.get_size() is used.
               If one element is -1 it is replaced by the corresponding valur from self.get_size().
        :pos: list, tuple: the new position; if (-1, -1), self.get_position is used.
              If one element is -1 it is replaced by the corresponding valur from self.get_position().
        :update: bool: whether to call the internal flush method."""
        if state not in (0, MINIMIZED, 'minimized', 1, NORMAL, 'normal', 2, MAXIMIZED, 'maximized', 3, FULLSCREEN, 'fullscreen'):
            # Raise a value error.
            raise ValueError("Invalid state argument: %s is not a correct value" % state)
        if not isinstance(size, (list, tuple)):
            raise TypeError("Invalid size argument: %s is not a list or a tuple.")
        if not isinstance(pos, (list, tuple)):
            raise TypeError("Invalid pos argument: %s is not a list or a tuple.")

        if state in (1, NORMAL, 'normal'):
            size = list(size)
            sz = self.get_size()
            if size[0] == -1:
                size[0] = sz[0]
            if size[1] == -1:
                size[1] = sz[1]
            pos = list(pos)
            ps = self.get_position()
            if pos[0] == -1:
                pos[0] = ps[0]
            if pos[1] == -1:
                pos[1] = ps[1]
            self.set_mode(size, self.mode)
            self.set_position(pos)
        elif state in (0, MINIMIZED, 'minimized'):
            pass
        elif state in (2, MAXIMIZED, 'maximized'):
            data = [1, self.display.intern_atom("_NET_WM_STATE_MAXIMIZED_VERT", False), self.display.intern_atom("_NET_WM_STATE_MAXIMIZED_HORZ", False)]
            data = (data + ([0] * (5 - len(data))))[:5]
            if DEBUG_WM:
                print self.stateHandler.get_wm_state()
                print "creating event", Xlib.protocol.event.ClientMessage
                print dir(self.stateHandler)
            x_event = Xlib.protocol.event.ClientMessage(window=self.stateHandler, client_type=self.display.intern_atom("_NET_WM_STATE", False), data=(32, data))
            if DEBUG_WM:
                print "sending event"
            self.display.screen().root.send_event(x_event, event_mask=Xlib.X.SubstructureRedirectMask)

            if DEBUG_WM:
                print self.stateHandler.get_wm_state()
        elif state in (3, FULLSCREEN, 'fullscreen'):
            pass
        if update:
            self.flush() 
開發者ID:Podshot,項目名稱:MCEdit-Unified,代碼行數:63,代碼來源:mcplatform.py


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