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


Python XK.keysym_to_string方法代码示例

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


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

示例1: __init__

# 需要导入模块: from Xlib import XK [as 别名]
# 或者: from Xlib.XK import keysym_to_string [as 别名]
    def __init__(self, keycode, modifiers, keysym):
        """Create an event instance.

        Arguments:

        keycode -- The keycode that identifies a physical key.

        modifiers -- An 8-bit mask. A set bit means the corresponding
        modifier is active. See Xlib.X.ShiftMask, Xlib.X.LockMask,
        Xlib.X.ControlMask, and Xlib.X.Mod1Mask through
        Xlib.X.Mod5Mask.

        keysym -- The symbol obtained when the key corresponding to
        keycode without any modifiers. The KeyboardEmulation class
        does not track modifiers such as Shift and Control.

        """
        self.keycode = keycode
        self.modifiers = modifiers
        self.keysym = keysym
        # Only want printable characters.
        if keysym < 255 or keysym in (XK.XK_Return, XK.XK_Tab):
            self.keystring = XK.keysym_to_string(keysym)
            if self.keystring == '\x00':
                self.keystring = None
        else:
            self.keystring = None
开发者ID:gcr,项目名称:plover,代码行数:29,代码来源:xkeyboardcontrol.py

示例2: wait

# 需要导入模块: from Xlib import XK [as 别名]
# 或者: from Xlib.XK import keysym_to_string [as 别名]
def wait(p_keys_list):
    """Block the whole keyboard!!! And wait until some key from p_keys_list
    is pressed. By now p_keys_list is a list of strings, so use single
    ascii symbols.
    There is a way out of this hell - hit 'Escape'.
    The function returns hit button`s string representation
    Eg. for p_keys_list == ['1','2','3'] the function will hand untill
    1,2 or 3 key is preseed or Escape is pressed."""
    ds = display
    window.grab_keyboard(1, X.GrabModeAsync, X.GrabModeAsync, X.CurrentTime)
    while True:
        ev = ds.next_event()
        if ev.type == X.KeyPress:
            keysym = ds.keycode_to_keysym(ev._data['detail'], 0)
            keystr = XK.keysym_to_string(keysym)
            print("Got keysym/keystr: "+str(keysym)+ ' / '+str(keystr))
            if keystr in p_keys_list:
                ds.ungrab_keyboard(X.CurrentTime)
                ds.flush()
                return keystr
            elif str(keysym) in p_keys_list:
                ds.ungrab_keyboard(X.CurrentTime)
                ds.flush()
                return keysym
            elif keysym == 65307:
                ds.ungrab_keyboard(X.CurrentTime)
                ds.flush()
                return 'Escape'
开发者ID:BrainTech,项目名称:openbci,代码行数:30,代码来源:keystroke.py

示例3: handler

# 需要导入模块: from Xlib import XK [as 别名]
# 或者: from Xlib.XK import keysym_to_string [as 别名]
    def handler(self, reply):
        """ Self function is called when a xlib event is fired """
        data = reply.data
        while len(data):
            event, data = rq.EventField(None).parse_binary_value(data,
                                                                 self.disp.display,
                                                                 None, None)

            if event.type == X.KeyPress:
                if event.detail == 36:
                    self.record("enter")
                elif event.detail == 22:
                    self.record("backspace")
                elif event.detail == 37:
                    self.record("control")
                elif event.detail == 64:
                    self.record("alt")
                elif event.detail == 108:
                    self.record("alt-gr")
                        
                key = XK.keysym_to_string(
                    self.disp.keycode_to_keysym(event.detail, event.state))

                if key:
                    self.record(key)
开发者ID:david-bergstrom,项目名称:pykeystat,代码行数:27,代码来源:keylistener.py

示例4: main

# 需要导入模块: from Xlib import XK [as 别名]
# 或者: from Xlib.XK import keysym_to_string [as 别名]
def main(options):
    # current display
    pid_file = "/var/lock/easyxmotion.pid"
    # kill any old versions that are still running,
    # we do it this way so the current one has input focus.
    # might be a better way to just exit and give focus to the old one.
    try:
        with open(pid_file, "r") as fp:
            pid = int(fp.read())
            try:
                os.kill(pid, signal.SIGTERM)
            except OSError:
                # other isn't running
                pass
    except IOError:
        # first ever run
        pass
    with open(pid_file, "w") as fp:
        fp.write(str(os.getpid()))

    osds, windows = display_osd(options)
    disp = Display()
    root = disp.screen().root
    root.change_attributes(event_mask=X.KeyPressMask)
    root.grab_keyboard(False, X.GrabModeAsync, X.GrabModeAsync, X.CurrentTime)

    event = disp.next_event()
    keycode = event.detail
    if event.type == X.KeyPress:
        key = XK.keysym_to_string(disp.keycode_to_keysym(keycode, 0))
        if key and key in string.lowercase and string.lowercase.index(key) < len(windows):
            windows[string.lowercase.index(key)].activate(timestamp)
        disp.ungrab_keyboard(X.CurrentTime)
        sys.exit()
开发者ID:liuexp,项目名称:arch-script,代码行数:36,代码来源:easyxmotion.py

示例5: keycode_to_string

# 需要导入模块: from Xlib import XK [as 别名]
# 或者: from Xlib.XK import keysym_to_string [as 别名]
 def keycode_to_string(self, key_code):
     codes_mod=[50,62,64,108,37,105,113,111,114,116,110,115,112,117,118,119,107,
                67,68,69,70,71,72,73,74,75,76,95,96
               ]
     names_mod=['Shift_L', 'Shift_R', 'Alt_L', 'Alt_R', 'Control_L', 'Control_R',
                'Left', 'Up', 'Right', 'Down', 'Home', 'End', 'Page_Up', 'Page_Down',
                'Insert', 'Delete', 'Print',
                'F1','F2','F3','F4','F5','F6','F7','F8','F9','F10','F11','F12'
               ]
     if key_code in codes_mod:
        return names_mod[codes_mod.index(key_code)]
     #2nd: 0 is unshifted, 1 is shifted, 2 is alt grid, and 3 is shiftalt grid
     return XK.keysym_to_string(self.disp.keycode_to_keysym(key_code, 0))        
开发者ID:lovesnow,项目名称:qdict,代码行数:15,代码来源:globalkey.py

示例6: keycode_to_string

# 需要导入模块: from Xlib import XK [as 别名]
# 或者: from Xlib.XK import keysym_to_string [as 别名]
def keycode_to_string(key_code):
    syms_mod=[65505,65506,65513,65514,65507,65508,
              65361,65362,65363,65364,65360,65367,65365,65366,
              65379,65535,65491,
              65470,65471,65472,65473,65474,65475,65476,65477,65478,65479,65480,65481
             ]
    names_mod=['Shift_L', 'Shift_R', 'Alt_L', 'Alt_R', 'Control_L', 'Control_R',
               'Left', 'Up', 'Right', 'Down', 'Home', 'End', 'Page_Up', 'Page_Down',
               'Insert', 'Delete', 'Print',
               'F1','F2','F3','F4','F5','F6','F7','F8','F9','F10','F11','F12'
               '\r'
              ]
    #2nd: 0 is unshifted, 1 is shifted, 2 is alt grid, and 3 is shiftalt grid
    key_sym=disp.keycode_to_keysym(key_code, 0)
    if key_sym in syms_mod:
       return names_mod[syms_mod.index(key_sym)]
    return XK.keysym_to_string(key_sym)
开发者ID:diyism,项目名称:MyBoard,代码行数:19,代码来源:myboard.py

示例7: code_to_char

# 需要导入模块: from Xlib import XK [as 别名]
# 或者: from Xlib.XK import keysym_to_string [as 别名]
 def code_to_char(cls, code, modifiers=0):
     if cls.device is "button":
         return "<%s>" % cls.key_to_name(code)
     if not cls.display:
         cls.display = Display()
     return XK.keysym_to_string(cls.display.keycode_to_keysym(code + 8, modifiers))
开发者ID:ILJICH,项目名称:PyBd,代码行数:8,代码来源:expression.py


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