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


Python XK.load_keysym_group方法代码示例

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


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

示例1: __init__

# 需要导入模块: from Xlib import XK [as 别名]
# 或者: from Xlib.XK import load_keysym_group [as 别名]
    def __init__(self, main_instance):
        """ Constructor """
        gobject.GObject.__init__(self)
        threading.Thread.__init__(self)
        self.setDaemon(True)
        self.running = False
        self.main = main_instance

        try:
            XK.load_keysym_group("xf86")
        except ImportError, err:
            log.warn("Xlib backend needs python-xlib 0.15rc1 or higher\n")
            raise ImportError(str(err))
开发者ID:JustinHop,项目名称:volti,代码行数:15,代码来源:xlibevent.py

示例2: __init__

# 需要导入模块: from Xlib import XK [as 别名]
# 或者: from Xlib.XK import load_keysym_group [as 别名]
    def __init__(self, display=None):
        PyKeyboardMeta.__init__(self)
        self.display = Display(display)
        self.root = self.display.screen().root
        
        XK.load_keysym_group('xkb')
        
        altList = self.display.keysym_to_keycodes(XK.XK_ISO_Level3_Shift)
        self.__usable_modifiers = (0, 1)
        for code, offset in altList:
            if code == 108 and offset == 0:
                self.__usable_modifiers += (4, 5)
                break
            
        mapping = self.display.get_modifier_mapping()
        self.modmasks = {}
        for keyname in MODIFIERS:
            keysym = XK.string_to_keysym(keyname)
            keycodes = self.display.keysym_to_keycodes(keysym)
            
            found = False
            for keycode, lvl in keycodes:
                for index, mask in MASK_INDEXES:
                    if keycode in mapping[index]:
                        self.modmasks[keycode] = mask
                        found = True
                    
                if found:
                    break
 
        self.flags = {        
            'Shift': X.ShiftMask,
            'Lock': X.LockMask,
            'Ctrl': X.ControlMask,
            'Alt': 0,
            'AltGr': self.modmasks[altList[0][0]],
            'Hankaku': 0}
        
        self.special_key_assignment()
开发者ID:nicolaselie,项目名称:pykuli,代码行数:41,代码来源:x11.py

示例3: __processMouseEvent

# 需要导入模块: from Xlib import XK [as 别名]
# 或者: from Xlib.XK import load_keysym_group [as 别名]
            self.handle_keyrelease(event.hw_code)

    def __processMouseEvent(self, event):
        if event.type[-1] == "p":
            button = int(event.type[-2])
            self.handle_mouseclick(button, event.detail1, event.detail2)

    def __pumpEvents(self):
        pyatspi.Registry.pumpQueuedEvents()
        return True


from iomediator import Key, MODIFIERS
from configmanager import *

XK.load_keysym_group("xkb")

XK_TO_AK_MAP = {
    XK.XK_Shift_L: Key.SHIFT,
    XK.XK_Shift_R: Key.SHIFT,
    XK.XK_Caps_Lock: Key.CAPSLOCK,
    XK.XK_Control_L: Key.CONTROL,
    XK.XK_Control_R: Key.CONTROL,
    XK.XK_Alt_L: Key.ALT,
    XK.XK_Alt_R: Key.ALT,
    XK.XK_ISO_Level3_Shift: Key.ALT_GR,
    XK.XK_Super_L: Key.SUPER,
    XK.XK_Super_R: Key.SUPER,
    XK.XK_Hyper_L: Key.HYPER,
    XK.XK_Hyper_R: Key.HYPER,
    XK.XK_Meta_L: Key.META,
开发者ID:valon0388,项目名称:autokey,代码行数:33,代码来源:interface.py

示例4: __processMouseEvent

# 需要导入模块: from Xlib import XK [as 别名]
# 或者: from Xlib.XK import load_keysym_group [as 别名]
    def __processMouseEvent(self, event):
        if event.type[-1] == 'p':
            button = int(event.type[-2])
            self.handle_mouseclick(button, event.detail1, event.detail2)

    def __pumpEvents(self):
        pyatspi.Registry.pumpQueuedEvents()
        return True

from .iomediator_constants import MODIFIERS
from .iomediator_Key import Key
# from .iomediator import Key, MODIFIERS
from .configmanager import *

XK.load_keysym_group('xkb')

XK_TO_AK_MAP = {
           XK.XK_Shift_L : Key.SHIFT,
           XK.XK_Shift_R : Key.SHIFT,
           XK.XK_Caps_Lock : Key.CAPSLOCK,
           XK.XK_Control_L : Key.CONTROL,
           XK.XK_Control_R : Key.CONTROL,
           XK.XK_Alt_L : Key.ALT,
           XK.XK_Alt_R : Key.ALT,
           XK.XK_ISO_Level3_Shift : Key.ALT_GR,
           XK.XK_Super_L : Key.SUPER,
           XK.XK_Super_R : Key.SUPER,
           XK.XK_Hyper_L : Key.HYPER,
           XK.XK_Hyper_R : Key.HYPER,
           XK.XK_Meta_L : Key.META,
开发者ID:bartekbrak,项目名称:autokey-py3,代码行数:32,代码来源:interface.py

示例5: dir

# 需要导入模块: from Xlib import XK [as 别名]
# 或者: from Xlib.XK import load_keysym_group [as 别名]
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from Xlib import XK
import KEYSYMDEF
_keysyms = [name for name in dir(KEYSYMDEF)]
for keysym in _keysyms:
    XK.__dict__[keysym] = KEYSYMDEF.__dict__[keysym]
del KEYSYMDEF

XK.load_keysym_group('miscellany')
XK.load_keysym_group('latin1')
XK.load_keysym_group('latin2')
XK.load_keysym_group('latin3')
XK.load_keysym_group('latin4')
XK.load_keysym_group('arabic')
XK.load_keysym_group('cyrillic')
XK.load_keysym_group('greek')
XK.load_keysym_group('hebrew')
XK.load_keysym_group('katakana')
XK.load_keysym_group('korean')
XK.load_keysym_group('publishing')
XK.load_keysym_group('thai')
XK.load_keysym_group('xkb')
XK.load_keysym_group('technical')
开发者ID:atareao,项目名称:Touchpad-Indicator,代码行数:32,代码来源:CONSTANTS.py

示例6: Display

# 需要导入模块: from Xlib import XK [as 别名]
# 或者: from Xlib.XK import load_keysym_group [as 别名]
		back=(0, 0, 0)):
	cursor_font = dpy.open_font('cursor')
	return cursor_font.create_glyph_cursor(cursor_font,
		cursor_idx, cursor_idx + 1,
		fore, back)

verbose = "-v" in sys.argv[1:]
dpy = Display()
root = dpy.screen().root

cursor = create_font_cursor(dpy, Xcursorfont.pirate)
active_cursor = create_font_cursor(dpy, Xcursorfont.pirate, fore=(0xffff, 0, 0))
esc_keycode = dpy.keysym_to_keycode(XK.XK_Escape)

# other intersting keys:
XK.load_keysym_group('xf86')
XK.XK_XF86_PowerOff
XK.XK_XF86_AudioMedia

print "# grab pointer:", root.grab_pointer(False,
	X.ButtonPressMask | X.ButtonReleaseMask,
	X.GrabModeAsync, X.GrabModeAsync, X.NONE, cursor, X.CurrentTime)
print "# grab keyboard:", root.grab_keyboard(False,
	X.GrabModeAsync, X.GrabModeAsync, X.CurrentTime)

# cheap.
import os
os.system('notify-send "XKidGrab" "Keyboard and mouse buttons grabbed.' +
	'  Exit by pressing Escape %d times."' % ESCAPE_COUNT)

active_cnt = 0
开发者ID:vamposdecampos,项目名称:xkidgrab,代码行数:33,代码来源:xkidgrab.py

示例7: this_should_be_a_module

# 需要导入模块: from Xlib import XK [as 别名]
# 或者: from Xlib.XK import load_keysym_group [as 别名]
def this_should_be_a_module():
	import Xlib
	import Xlib.display
	from Xlib import X, XK
	import Xlib.keysymdef
	for group in Xlib.keysymdef.__all__:
		XK.load_keysym_group(group)

	mods = {"c": X.ControlMask, "s": X.ShiftMask, "w": X.Mod4Mask, "a": X.Mod1Mask}
	modmask = 0
	for mod in mods:
		modmask |= mods[mod]

	def parse_key(k):
		(*parts, sym) = k.split("-")
		modmask = 0
		for mod in parts:
			modmask |= mods[mod]
		keysym = XK.string_to_keysym(sym)
		if keysym == 0:
			print("Invalid key '%s'" % parts)
		return (keysym, modmask)

	display = Xlib.display.Display()
	bound = {}
	all_keys = {}
	def regrab_keys():
		root = display.screen().root

		for key in bound.keys():
			root.ungrab_key(key[0], key[1])
		display.sync()

		bound.clear()
		grab_keys(all_keys)

	def grab_keys(keys):
		for (code, mask), func in keys.items():
			code = display.keysym_to_keycode(code)
			if (code, mask) == (0, 0):
				continue
			bound[code, mask] = func
			bound[code, mask | X.Mod2Mask] = func
			bound[code, mask | X.LockMask] = func
			bound[code, mask | X.Mod2Mask | X.LockMask] = func

		root = display.screen().root
		for key in bound.keys():
			root.grab_key(key[0], key[1], 1, X.GrabModeAsync, X.GrabModeAsync)
		display.sync()

	def bind(keys):
		keys = {parse_key(k): f for k, f in keys.items()}
		grab_keys(keys)
		all_keys.update(keys)

	def start():
		def on_event():
			nonlocal bound
			while display.pending_events():
				evt = display.next_event()
				if evt.type == X.KeyPress:
					k = (evt.detail, evt.state & modmask)
					if k in bound:
						asyncio.ensure_future(bound[k]())
				if evt.type == X.MappingNotify and evt.request == X.MappingKeyboard:
					display.refresh_keyboard_mapping(evt)
					regrab_keys()
		asyncio.get_event_loop().add_reader(display.fileno(), on_event)
		asyncio.get_event_loop().run_forever()
	return bind, start
开发者ID:Caagr98,项目名称:Dotfiles,代码行数:73,代码来源:i3kb.py


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