本文整理汇总了Python中gi.repository.Keybinder.unbind方法的典型用法代码示例。如果您正苦于以下问题:Python Keybinder.unbind方法的具体用法?Python Keybinder.unbind怎么用?Python Keybinder.unbind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Keybinder
的用法示例。
在下文中一共展示了Keybinder.unbind方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bind_key
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import unbind [as 别名]
def bind_key(keystr, keybinding_target=KEYBINDING_DEFAULT):
"""
Bind @keystr, unbinding any previous key for @keybinding_target.
If @keystr is a false value, any previous key will be unbound.
"""
keybinding_target = int(keybinding_target)
if Keybinder is None:
return False
def callback(keystr):
return GetKeyboundObject()._keybinding(keybinding_target)
if not _is_sane_keybinding(keystr):
pretty.print_error(__name__, "Refusing to bind key", repr(keystr))
return False
succ = True
if keystr:
try:
succ = Keybinder.bind(keystr, callback)
pretty.print_debug(__name__, "binding", repr(keystr))
GetKeyboundObject().emit_bound_key_changed(keystr, True)
except KeyError as exc:
pretty.print_error(__name__, exc)
succ = False
if succ:
old_keystr = get_currently_bound_key(keybinding_target)
if old_keystr and old_keystr != keystr:
Keybinder.unbind(old_keystr)
pretty.print_debug(__name__, "unbinding", repr(old_keystr))
GetKeyboundObject().emit_bound_key_changed(old_keystr, False)
_register_bound_key(keystr, keybinding_target)
return succ
示例2: cancel
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import unbind [as 别名]
def cancel(self):
if not self._callback:
return
for keystring in self._worked:
Keybinder.unbind(keystring)
del self._worked[:]
self._callback = None
示例3: unbinder
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import unbind [as 别名]
def unbinder(self, items):
for keystring in items:
try:
Keybinder.unbind(items[keystring])
except:
pass
HotKeysConfig.binded = False
示例4: rebind_key
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import unbind [as 别名]
def rebind_key(keystring, is_bound):
if is_bound:
print("binding", keystring)
keybinder.bind(keystring, relay_key, keystring)
else:
print("unbinding", keystring)
keybinder.unbind(keystring)
示例5: bind_key
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import unbind [as 别名]
def bind_key(cls):
Keybinder.init()
shortcut = MetaData.get_snapshoot_shortcut()
if Keybinder.bind(shortcut,cls.callback,""):
if cls.old_key_shortcut is not None:
Keybinder.unbind(cls.old_key_shortcut)
cls.old_key_shortcut = shortcut
else:
logging.error("Bind shortcut key failed ")
示例6: bind
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import unbind [as 别名]
def bind(binding, func, *args, **kwargs):
"""Wrapper for keybinder.bind() allowing kwargs."""
def run(_, __): func(*args, **kwargs)
try:
Keybinder.unbind(binding)
except:
pass
success = Keybinder.bind(binding, run, None)
if not success:
print "Error binding '%s'" % binding
示例7: set_app_show
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import unbind [as 别名]
def set_app_show(self, new):
'''
This is a specific method to set just the show accelerator.
We use the value from gsettings to first unbind the current
key, so in the process of changing the hotkey, we expect the
API user to first call this method and later change gsettings.
'''
if platform.system() == 'Windows':
self.app.set_hotkey(new)
else:
Keybinder.unbind(self.shortcuts['app-show'])
Keybinder.bind(new, self.app.on_show)
示例8: bind_show_app_hotkey
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import unbind [as 别名]
def bind_show_app_hotkey(self, accel_name):
if is_wayland_compatibility_on():
return
if self._current_accel_name == accel_name:
return
if self._current_accel_name:
Keybinder.unbind(self._current_accel_name)
self._current_accel_name = None
logger.info("Trying to bind app hotkey: %s" % accel_name)
Keybinder.bind(accel_name, self.toggle_window)
self._current_accel_name = accel_name
self.notify_hotkey_change(accel_name)
示例9: bind_tab
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import unbind [as 别名]
def bind_tab(self, bind=True):
if bind:
Keybinder.bind(self.super + 'Tab', self.tab_key, False)
Keybinder.bind(self.super + '<Shift>Tab', self.tab_key, True)
for i, key in enumerate(self.monkeys):
Keybinder.bind(self.super + '<Ctrl>' + key,
self.tab_key, False, i)
Keybinder.bind(self.super + '<Ctrl><Shift>' + key,
self.tab_key, False, i)
else:
Keybinder.unbind(self.super + 'Tab')
Keybinder.unbind(self.super + '<Shift>Tab')
for i, key in enumerate(self.monkeys):
Keybinder.unbind(self.super + '<Ctrl>' + key)
Keybinder.unbind(self.super + '<Ctrl><Shift>' + key)
示例10: teardown
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import unbind [as 别名]
def teardown(self, exaile):
for k in KEYS:
Keybinder.unbind(k)
示例11: _unbind
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import unbind [as 别名]
def _unbind(self, hotkey):
Keybinder.unbind(self._gtk_hotkey(hotkey))
示例12: disable
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import unbind [as 别名]
def disable(exaile):
for k in KEYS:
Keybinder.unbind(k)
示例13: set_app_show
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import unbind [as 别名]
def set_app_show(self, new):
"""
We expect gsettings hasn't been changed yet.
"""
Keybinder.unbind(self.shortcuts["app-show"])
Keybinder.bind(new, self.app.on_show)
示例14: unbind_keys
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import unbind [as 别名]
def unbind_keys(self):
for keystring in self.bound_keys:
Keybinder.unbind(keystring)
self.bound_keys = []