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


Python Keybinder.bind方法代码示例

本文整理汇总了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)
开发者ID:engla,项目名称:kupfer,代码行数:9,代码来源:keyrelay.py

示例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)
开发者ID:BlubberHarpoonist,项目名称:exaile,代码行数:9,代码来源:__init__.py

示例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()
开发者ID:sbillaudelle,项目名称:paparazzo,代码行数:12,代码来源:paparazzo.py

示例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)
开发者ID:gbtami,项目名称:passman,代码行数:14,代码来源:dialogs.py

示例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
开发者ID:bwann,项目名称:anaconda,代码行数:54,代码来源:__init__.py

示例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.")
开发者ID:hardyoyo,项目名称:kazam,代码行数:53,代码来源:indicator.py

示例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)
开发者ID:Ulauncher,项目名称:Ulauncher,代码行数:17,代码来源:UlauncherWindow.py

示例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()
开发者ID:gillesB,项目名称:azulejo,代码行数:17,代码来源:azulejo.py

示例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)
开发者ID:foss-np,项目名称:anubad,代码行数:17,代码来源:linux.py

示例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
开发者ID:albfan,项目名称:terminator,代码行数:28,代码来源:window.py

示例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)
开发者ID:Gordon01,项目名称:smarthome,代码行数:9,代码来源:x11.py

示例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
开发者ID:engla,项目名称:kupfer,代码行数:36,代码来源:keybindings.py

示例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)
开发者ID:zsau,项目名称:quodlibet,代码行数:9,代码来源:keybinder.py

示例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
开发者ID:exaile,项目名称:exaile,代码行数:11,代码来源:__init__.py

示例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 ")
开发者ID:ChanningBJ,项目名称:ElsaClipper,代码行数:11,代码来源:main_ui.py


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