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


Python Keybinder.init方法代码示例

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


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

示例1: init_keybinder

# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import init [as 别名]
	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,代码行数:9,代码来源:Tida.py

示例2: _enable

# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import init [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: bind_key

# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import init [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

示例4: on_exaile_loaded

# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import init [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

示例5: __init__

# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import init [as 别名]
    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,代码行数:11,代码来源:montab.py

示例6: __init__

# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import init [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

示例7: __init__

# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import init [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()
            # 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,代码行数:56,代码来源:indicator.py

示例8: __init__

# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import init [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

示例9: __init__

# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import init [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

示例10: plugin_main

# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import init [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

示例11: finish_initializing

# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import init [as 别名]
    def finish_initializing(self, builder):
        """Called while initializing this instance in __new__

        finish_initializing should be called after parsing the UI definition
        and creating a UlauncherWindow object with it in order to finish
        initializing the start of the new UlauncherWindow instance.
        """
        # Get a reference to the builder and set up the signals.
        self.builder = builder
        self.ui = builder.get_ui(self, True)
        self.PreferencesDialog = None  # class
        self.preferences_dialog = None  # instance

        self.results_nav = None
        self.window = self.ui['ulauncher_window']
        self.input = self.ui['input']
        self.prefs_btn = self.ui['prefs_btn']
        self.result_box = self.ui["result_box"]

        self.input.connect('changed', self.on_input_changed)
        self.prefs_btn.connect('clicked', self.on_mnu_preferences_activate)

        self.set_keep_above(True)

        self.PreferencesDialog = PreferencesUlauncherDialog
        self.settings = Settings.get_instance()

        self.fix_window_width()
        self.position_window()
        self.init_theme()

        # this will trigger to show frequent apps if necessary
        self.show_results([])

        if not is_wayland_compatibility_on():
            # bind hotkey
            Keybinder.init()
            accel_name = self.settings.get_property('hotkey-show-app')
            # bind in the main thread
            GLib.idle_add(self.bind_show_app_hotkey, accel_name)

        start_app_watcher()
        ExtensionServer.get_instance().start()
        time.sleep(0.01)
        ExtensionRunner.get_instance().run_all()
        ExtensionDownloader.get_instance().download_missing()
开发者ID:Ulauncher,项目名称:Ulauncher,代码行数:48,代码来源:UlauncherWindow.py

示例12: __init__

# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import init [as 别名]
	def __init__(self):
		Gtk.Window.__init__(self, type=Gtk.WindowType.TOPLEVEL)
		Keybinder.init()

		# Deactivating WM keybindings
		keybindings = Gio.Settings.new('org.gnome.desktop.wm.keybindings')
		wm_hotkey = lambda t: keybindings.get_value(t)[0]
		if wm_hotkey('switch-input-source') or wm_hotkey('switch-input-source-backward'):
			self.show_message("Unity-Kbd-Switcher is going to deactivate the following WM keybindings\n"
				+ "You can set them later in settings if you'll decide to discontinue using.\n"
				+ "\n"
				+ "switch-input-source: " + wm_hotkey('switch-input-source') + "\n"
				+ "switch-input-source-backward: " + wm_hotkey('switch-input-source-backward') + "\n")
			keybindings.set_value('switch-input-source', GLib.Variant('as', ['']))
			keybindings.set_value('switch-input-source-backward', GLib.Variant('as', ['']))

		# Initializing GSettings
		self.source_settings = Gio.Settings.new('org.gnome.desktop.input-sources')
		self.source_settings.connect("changed::current", self.on_current_changed)
		self.source_settings.connect("changed::sources", self.on_sources_changed)

		# Loading config
		rc = "%s/.kbdrc" % os.getenv("HOME")
		if not os.path.isfile(rc):
			self.generate_default_rc(rc)
		keymap = {}
		execfile(rc)
		self.keymap = keymap

		self.current_layout = None
		self.on_sources_changed(None, None)
		self.on_current_changed(None, None)

		# Binding global hotkeys
		for key in self.keymap.keys():
			print "Binding %s" % key
			if not Keybinder.bind(key, self.on_global_key_activated, None):
				self.show_message("Could not bind '%s'" % key)
		
		# Usual Gtk Stuff
		self.connect("destroy", Gtk.main_quit)
		self.connect("delete_event", Gtk.main_quit)
		signal.signal(signal.SIGINT, signal.SIG_DFL)
		internals.app = self
		Gtk.main()
开发者ID:vdudouyt,项目名称:unity-kbd-switcher,代码行数:47,代码来源:main.py

示例13: bind_keybinder

# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import init [as 别名]
 def bind_keybinder(self):
     try:
         import gi
         gi.require_version('Keybinder', '3.0')
         # Gdk needed for Keybinder
         from gi.repository import Keybinder
         Keybinder.init()
     except (ValueError, ImportError):
         return False
     
     Keybinder.bind('XF86AudioPlay', self.window.playpause, None)
     Keybinder.bind('XF86AudioStop', self.window.user_pause, None)
     Keybinder.bind('XF86AudioNext', self.window.next_song, None)
     Keybinder.bind('XF86AudioPrev', self.window.bring_to_top, None)
     
     logging.info("Bound media keys with keybinder")
     self.method = 'keybinder'
     return True
开发者ID:NightBuilder,项目名称:pithos,代码行数:20,代码来源:mediakeys.py

示例14: on_startup

# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import init [as 别名]
 def on_startup(self, app):
     '''
     This method handles the startup signal.
     As per GNOME guidelines this is where most of
     the work to create the window should be done.
     '''
     self.create_directories()
     
     self.settings = Gio.Settings(schema=self.schema_id + '.preferences')
     self.win_settings = Gio.Settings(schema=self.schema_id + '.window')
     self.width = self.win_settings['width']
     self.height = self.win_settings['height']
     self.general_settings = self.settings.get_child('general')
     self.set_autostart(self.general_settings['autostart'])
     self.closehide = self.general_settings['closehide']
     self.about_dialog = None
     self.preferences_dialog = None
     logging.basicConfig(filename=self.log_file, level=logging.DEBUG,
                         format='%(asctime)s %(levelname)s: %(message)s')
     
     self.window = Gtk.ApplicationWindow(application=app)
     self.window.connect('size-allocate', self.on_size_allocate)
     self.window.connect('delete-event', self.on_window_delete)
     self.window.set_title(self.title)
     self.window.set_default_size(self.width, self.height)
     self.window.set_position(Gtk.WindowPosition.MOUSE)
     self.window.set_titlebar(HeaderBar(self))
     # We need to set the icon here as a backup, the gnome system monitor
     # for instance, and for whatever reason, doesn't choose the right icon
     # sometimes, particularly after hiding the window, and showing again.
     self.window.set_icon_name(self.icon)
     self.main_view = MainView(self)
     self.window.add(self.main_view)
     
     self.add_actions()
     builder = Gtk.Builder.new_from_file(self.gui_ui)
     app_menu = builder.get_object('app_menu')
     self.set_app_menu(app_menu)
     
     Keybinder.init()
     shortcuts = self.settings.get_child('shortcuts')
     Keybinder.bind(shortcuts['app-show'], self.on_show)
开发者ID:ysk9,项目名称:passman,代码行数:44,代码来源:application.py

示例15: add_global_shortcut

# 需要导入模块: from gi.repository import Keybinder [as 别名]
# 或者: from gi.repository.Keybinder import init [as 别名]
 def add_global_shortcut(self):
     '''
     This method adds a global shortcut,
     the shortcut used to show the application.
     '''
     shortcuts = self.settings.get_child('shortcuts')
     if platform.system() == 'Windows':
         self.modifiers = {Gdk.ModifierType.SHIFT_MASK:
                               ['VK_SHIFT'],
                           Gdk.ModifierType.CONTROL_MASK:
                               ['VK_CONTROL'],
                           Gdk.ModifierType.MOD1_MASK:
                               ['VK_MENU'],
                           Gdk.ModifierType.SUPER_MASK:
                               ['VK_LWIN', 'VK_RWIN']}
         hook_manager = pyHook.HookManager()
         hook_manager.KeyDown = self.on_keyboard_event
         self.set_hotkey(shortcuts['app-show'])
         hook_manager.HookKeyboard()
     else:
         Keybinder.init()
         Keybinder.bind(shortcuts['app-show'], self.on_show)
开发者ID:gbtami,项目名称:passman,代码行数:24,代码来源:application.py


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