本文整理汇总了Python中gi.repository.Keybinder.bind方法的典型用法代码示例。如果您正苦于以下问题:Python Keybinder.bind方法的具体用法?Python Keybinder.bind怎么用?Python Keybinder.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Keybinder
的用法示例。
在下文中一共展示了Keybinder.bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rebind_key
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import bind [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)
示例2: _enable
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import bind [as 别名]
def _enable(eventname, exaile, eventdata):
global initialized
if not initialized:
Keybinder.init()
initialized = True
for k in KEYS:
Keybinder.bind(k, on_media_key, exaile)
示例3: __init__
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import bind [as 别名]
def __init__(self):
self.recorder = Recorder()
keybinder.init()
keybinder.bind('<Control>Escape', self.callback, None)
self.overlay = Overlay()
self.overlay.connect('trigger', lambda *args: self.start_recording(*self.overlay.get_selection()))
self.overlay.show_all()
示例4: set_app_show
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import bind [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)
示例5: __init__
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import bind [as 别名]
def __init__(self, data):
"""Create a new UIObject instance, including loading its uiFile and
all UI-related objects.
Instance attributes:
data -- An instance of a pykickstart Handler object. The Hub
never directly uses this instance. Instead, it passes
it down into Spokes when they are created and applied.
The Hub simply stores this instance so it doesn't need
to be passed by the user.
skipTo -- If this attribute is set to something other than None,
it must be the name of a class (as a string). Then,
the interface will skip to the first instance of that
class in the action list instead of going on to
whatever the next action is normally.
Note that actions may only skip ahead, never backwards.
Also, standalone spokes may not skip to an individual
spoke off a hub. They can only skip to the hub
itself.
"""
common.UIObject.__init__(self, data)
if self.__class__ is GUIObject:
raise TypeError("GUIObject is an abstract class")
self.skipTo = None
self.applyOnSkip = False
self.builder = Gtk.Builder()
self.builder.set_translation_domain(self.translationDomain)
self._window = None
if self.builderObjects:
self.builder.add_objects_from_file(self._findUIFile(), self.builderObjects)
else:
self.builder.add_from_file(self._findUIFile())
self.builder.connect_signals(self)
# Keybinder from GI needs to be initialized before use
Keybinder.init()
Keybinder.bind("<Shift>Print", self._handlePrntScreen, [])
self._automaticEntry = False
self._autostepRunning = False
self._autostepDone = False
self._autostepDoneCallback = None
# this indicates if the screen is the last spoke to be processed for a hub
self.lastAutostepSpoke = False
示例6: __init__
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import bind [as 别名]
def __init__(self, silent = False):
super(KazamSuperIndicator, self).__init__()
self.blink_icon = BLINK_STOP_ICON
self.blink_state = False
self.blink_mode = BLINK_SLOW
self.recording = False
self.silent = silent
logger.debug("Indicatior silent: {0}".format(self.silent))
self.menu = Gtk.Menu()
self.menuitem_start = Gtk.MenuItem(_("Start recording"))
self.menuitem_start.set_sensitive(True)
self.menuitem_start.connect("activate", self.on_menuitem_start_activate)
self.menuitem_pause = Gtk.CheckMenuItem(_("Pause recording"))
self.menuitem_pause.set_sensitive(False)
self.menuitem_pause.connect("toggled", self.on_menuitem_pause_activate)
self.menuitem_finish = Gtk.MenuItem(_("Finish recording"))
self.menuitem_finish.set_sensitive(False)
self.menuitem_finish.connect("activate", self.on_menuitem_finish_activate)
self.menuitem_separator = Gtk.SeparatorMenuItem()
self.menuitem_quit = Gtk.MenuItem(_("Quit"))
self.menuitem_quit.connect("activate", self.on_menuitem_quit_activate)
self.menu.append(self.menuitem_start)
self.menu.append(self.menuitem_pause)
self.menu.append(self.menuitem_finish)
self.menu.append(self.menuitem_separator)
self.menu.append(self.menuitem_quit)
self.menu.show_all()
#
# Setup keybindings - Hardcore way
#
try:
from gi.repository import Keybinder
logger.debug("Trying to bind hotkeys.")
Keybinder.init()
Keybinder.bind("<Super><Ctrl>R", self.cb_hotkeys, "start-request")
Keybinder.bind("<Super><Ctrl>F", self.cb_hotkeys, "stop-request")
Keybinder.bind("<Super><Ctrl>P", self.cb_hotkeys, "pause-request")
Keybinder.bind("<Super><Ctrl>W", self.cb_hotkeys, "show-request")
Keybinder.bind("<Super><Ctrl>Q", self.cb_hotkeys, "quit-request")
self.recording = False
except ImportError:
logger.info("Unable to import Keybinder, hotkeys not available.")
示例7: bind_show_app_hotkey
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import bind [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)
示例8: __init__
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import bind [as 别名]
def __init__(self):
self.bound_keys = []
self.workarea = Workarea()
self.callable_actions = dict
self.__define_callable_actions()
notify2.init("Azulejo")
Keybinder.init()
Keybinder.bind("<Super>y", WindowTools.print_window_info, None)
Keybinder.bind("<Super>c", self.switch_config_files, None)
self.bind_keys(configuration.get_config_data_first_time())
Gtk.main()
示例9: plugin_main
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import bind [as 别名]
def plugin_main(app, fullpath):
import gi
gi.require_version('Notify', '0.7')
gi.require_version('Keybinder', '3.0')
from gi.repository import Keybinder, Notify
global notification
notification = Notify.Notification()
Keybinder.init()
Keybinder.bind("<Ctrl><Alt>v", lambda *a: grab_notify(app))
Keybinder.bind("<Ctrl><Alt>m", lambda *a: notifier(app))
Notify.init("anubad")
notification.set_icon_from_pixbuf(app.pixbuf_logo)
示例10: register_callbacks
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import bind [as 别名]
def register_callbacks(self):
"""Connect the GTK+ signals we care about"""
self.connect('key-press-event', self.on_key_press)
self.connect('button-press-event', self.on_button_press)
self.connect('delete_event', self.on_delete_event)
self.connect('destroy', self.on_destroy_event)
self.connect('window-state-event', self.on_window_state_changed)
self.connect('focus-out-event', self.on_focus_out)
self.connect('focus-in-event', self.on_focus_in)
# Attempt to grab a global hotkey for hiding the window.
# If we fail, we'll never hide the window, iconifying instead.
if self.config['keybindings']['hide_window'] != None:
if display_manager() == 'X11':
try:
self.hidebound = Keybinder.bind(
self.config['keybindings']['hide_window'].replace('<Shift>',''),
self.on_hide_window)
except (KeyError, NameError):
pass
if not self.hidebound:
err('Unable to bind hide_window key, another instance/window has it.')
self.hidefunc = self.iconify
else:
self.hidefunc = self.hide
示例11: _bind
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import bind [as 别名]
def _bind(self, hotkey, func):
gtk_hotkey = self._gtk_hotkey(hotkey)
bound = Keybinder.bind(gtk_hotkey, lambda *args, **kwargs: func())
if bound:
logger.debug("Bound hotkey %r (gtk_hotkey = %r)", hotkey, gtk_hotkey)
else:
logger.error("Unable to bind hotkey %r (gtk_hotkey = %r)", hotkey, gtk_hotkey)
示例12: bind_key
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import bind [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
示例13: __init__
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import bind [as 别名]
def __init__(self, name, callback):
self._callback = callback
self._worked = []
for keystring, action in self._EVENTS.items():
if Keybinder.bind(keystring, self._bind_cb, None):
self._worked.append(keystring)
示例14: on_exaile_loaded
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import bind [as 别名]
def on_exaile_loaded(self):
if not self.__exaile:
return # Plugin has been disabled in the meantime
Keybinder.init()
for k in KEYS:
if not Keybinder.bind(k, on_media_key, self.__exaile):
LOGGER.warning("Failed to set key binding using Keybinder.")
self.__exaile.plugins.disable_plugin(__name__)
return
示例15: bind_key
# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import bind [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 ")