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


Python repository.Keybinder类代码示例

本文整理汇总了Python中gi.repository.Keybinder的典型用法代码示例。如果您正苦于以下问题:Python Keybinder类的具体用法?Python Keybinder怎么用?Python Keybinder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: bind_key

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,代码行数:34,代码来源:keybindings.py

示例2: unbinder

 def unbinder(self, items):
     for keystring in items:
         try:
             Keybinder.unbind(items[keystring])
         except:
             pass
     HotKeysConfig.binded = False
开发者ID:zablotski,项目名称:foobnix,代码行数:7,代码来源:hotkey_conf.py

示例3: cancel

 def cancel(self):
     if not self._callback:
         return
     for keystring in self._worked:
         Keybinder.unbind(keystring)
     del self._worked[:]
     self._callback = None
开发者ID:zsau,项目名称:quodlibet,代码行数:7,代码来源:keybinder.py

示例4: init_keybinder

	def init_keybinder(self, config):
		"""Initialise keybinder and bind some keys (toggle, copy, paste)"""
		Keybinder.init()
		Keybinder.set_use_cooked_accelerators(False)
		self.bind_all_key(config['key_toggle_visibility'],
							config['key_copy_to_clipboard'],
							config['key_paste_from_clipboard'])
开发者ID:headlins,项目名称:tida,代码行数:7,代码来源:Tida.py

示例5: _enable

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,代码行数:7,代码来源:__init__.py

示例6: bind_key

 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,代码行数:9,代码来源:main_ui.py

示例7: on_exaile_loaded

 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,代码行数:9,代码来源:__init__.py

示例8: __init__

    def __init__(self, superkey='<Super>'):
        self.montab = MonTab()
        self.super = superkey

        nmons = self.montab.screen.get_n_monitors()
        self.monkeys = [chr(ord('1') + n) for n in range(nmons)]

        Keybinder.init()
        Keybinder.set_use_cooked_accelerators(False)
开发者ID:rabinv,项目名称:montab,代码行数:9,代码来源:montab.py

示例9: __init__

    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()
            # 2015-10-10, Joshua Chen
            # configure the shortcut keys
            Keybinder.bind("<Ctrl><Shift>F1", self.cb_hotkeys, "start-request")
            Keybinder.bind("<Ctrl><Shift>F12", self.cb_hotkeys, "stop-request")
            Keybinder.bind("<Ctrl><Shift>F8", self.cb_hotkeys, "pause-request")
            # Keybinder.bind("<Ctrl>W", self.cb_hotkeys, "show-request")
            Keybinder.bind("<Ctrl><Shift>F11", self.cb_hotkeys, "quit-request")
            self.recording = False
        except ImportError:
            logger.info("Unable to import Keybinder, hotkeys not available.")
开发者ID:iesugrace,项目名称:kazam-custom,代码行数:54,代码来源:indicator.py

示例10: bind

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
开发者ID:mntnoe,项目名称:wmbinder,代码行数:11,代码来源:commands.py

示例11: set_app_show

 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,代码行数:12,代码来源:dialogs.py

示例12: __init__

    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,代码行数:52,代码来源:__init__.py

示例13: bind_show_app_hotkey

    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,代码行数:15,代码来源:UlauncherWindow.py

示例14: hide_app

    def hide_app(self, key_bind_hide, user_data):
        self.last_event_time = Keybinder.get_current_event_time()
        print("Event time:", self.last_event_time)

        self.wnck.force_update()
        self.active_workspace = self.wnck.get_active_workspace()
        # 		print("Workspaces:", self.wnck.get_workspaces())
        # 		print("Active workspace:", self.active_workspace)
        # 		print("Last active workspace:", self.last_active_workspace)
        #
        if self.is_present:
            print("Hiding app")
            if self.parent.is_drop_down:
                self.hide()
            else:
                self.iconify()
            self.is_present = False

        else:
            print("Showing app")
            if self.parent.is_drop_down:
                if self.last_active_workspace != self.active_workspace:
                    self.last_active_workspace = self.active_workspace
                    self.hide()

                self.show()
            # 				self.present()
            # 				self.set_icon_from_file(config.file_program_icon)

            self.present_with_time(self.last_event_time)
            self.main_box.active_term.grab_focus()
            self.is_present = True
开发者ID:keiwop,项目名称:test_gtk3_terminal,代码行数:32,代码来源:nameless_main_window.py

示例15: register_callbacks

    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,代码行数:26,代码来源:window.py


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