Python gi.repository.Gdk.keyval_name() Examples
The following are 30
code examples of gi.repository.Gdk.keyval_name().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
gi.repository.Gdk
, or try the search function
.
Example #1
Source File: widgets.py From badKarma with GNU General Public License v3.0 | 7 votes |
def _key_press_event(self, widget, event): # Vte terminal key press event, # allow Copy/Paste in the terminal keyval = event.keyval keyval_name = Gdk.keyval_name(keyval) state = event.state ctrl = (state & Gdk.ModifierType.CONTROL_MASK) shift = (state & Gdk.ModifierType.SHIFT_MASK) if ctrl and shift and keyval_name == 'C': # Ctrl+Shit+C - copy self.copy_clipboard_format(Vte.Format.TEXT) if ctrl and shift and keyval_name == 'V': # Ctrl+Shit+V - paste self.paste_clipboard()
Example #2
Source File: gtk_ui.py From python-gui with Apache License 2.0 | 6 votes |
def _gtk_key(self, widget, event, *args): # This function was adapted from pangoterm source code keyval = event.keyval state = event.state # GtkIMContext will eat a Shift-Space and not tell us about shift. # Also don't let IME eat any GDK_KEY_KP_ events done = (False if state & SHIFT and keyval == ord(' ') else False if Gdk.KEY_KP_Space <= keyval <= Gdk.KEY_KP_Divide else self._im_context.filter_keypress(event)) if done: # input method handled keypress return True if event.is_modifier: # We don't need to track the state of modifier bits return # translate keyval to nvim key key_name = Gdk.keyval_name(keyval) if key_name.startswith('KP_'): key_name = key_name[3:] input_str = _stringify_key(KEY_TABLE.get(key_name, key_name), state) self._bridge.input(input_str)
Example #3
Source File: __init__.py From zim-desktop-wiki with GNU General Public License v2.0 | 6 votes |
def do_key_press_event(self, event): # Keybindings for the treeview: # Ctrl-C copy link to selected page # Ctrl-L insert link to selected page in pageview # Keybindings for collapsing and expanding items are # implemented in the BrowserTreeView parent class # And MainWindow hooks Esc to close side pane handled = False #~ print('KEY %s (%i)' % (Gdk.keyval_name(event.keyval), event.keyval)) if event.get_state() & PRIMARY_MODIFIER_MASK: if event.keyval == KEYVAL_C: self.emit('copy') handled = True elif event.keyval == KEYVAL_L: path = self.get_selected_path() #~ print('!! insert-link', path) self.emit('insert-link', path) handled = True return handled \ or BrowserTreeView.do_key_press_event(self, event)
Example #4
Source File: __main__.py From razerCommander with GNU General Public License v3.0 | 6 votes |
def on_recordKeystrokeToggleBtn_key_release_event(self, toggle_btn, event): if toggle_btn.get_active(): keyname = Gdk.keyval_name(event.keyval) self.key_stroke_n -= 1 if not self.key_stroke_n: keystroke = '' for i in range(0, 4): if self.keystroke_shortcuts_all_mods[i].get_active(): keystroke += self.keystroke_shortcuts_all_mods_str[i]+'+' keystroke += '+'.join(self.key_stroke_list) self.macro_current_keystroke_label.set_text(keystroke) self.key_stroke_list = [] self.key_stroke_n = 0 toggle_btn.set_active(False) else: self.key_stroke_n = 0 self.key_stroke_list = [] # Handler functions END
Example #5
Source File: dialog.py From Dindo-Bot with MIT License | 6 votes |
def on_key_press(self, widget, event): # get keyname keyname = Gdk.keyval_name(event.keyval) # check combinations if event.state & Gdk.ModifierType.CONTROL_MASK: shortcut = 'Ctrl+%s' % keyname elif event.state & Gdk.ModifierType.MOD1_MASK: shortcut = 'Alt+%s' % keyname elif event.state & Gdk.ModifierType.SHIFT_MASK: shortcut = 'Shift+%s' % keyname else: shortcut = keyname # show shortcut self.shortcut_label.set_markup('<b>%s</b>' % shortcut) # hide error box self.error_box.hide() # stop event propagation return True
Example #6
Source File: jogging.py From hazzy with GNU General Public License v2.0 | 6 votes |
def on_key_release_event(widget, event): keyname = Gdk.keyval_name(event.keyval) if not keyname in KEYBINDINGS: return False if not is_pressed.get(keyname, False): return False is_pressed[keyname] = False # stat.poll() # if stat.task_mode != linuxcnc.MODE_MANUAL \ # or not stat.enabled \ # or not is_homed(): # return jog_stop(KEYBINDINGS[keyname]) return True
Example #7
Source File: jogging.py From hazzy with GNU General Public License v2.0 | 6 votes |
def on_key_press_event(widget, event): keyname = Gdk.keyval_name(event.keyval) if not keyname in KEYBINDINGS: return False if is_pressed.get(keyname, False): return True if not prefs.get('JOGGING', 'USE_KEYBOARD', 'YES', bool): return False stat.poll() if stat.task_mode != linuxcnc.MODE_MANUAL \ or not stat.enabled \ or not is_homed(): return False is_pressed[keyname] = True jog_start(KEYBINDINGS[keyname]) is_pressed[keyname] = True return True
Example #8
Source File: touchpad.py From hazzy with GNU General Public License v2.0 | 5 votes |
def on_numpad_key_release_event(self, widget, event): key_name = Gdk.keyval_name(event.keyval) log.debug("key pressed from keyboard: {0}".format(key_name))
Example #9
Source File: main.py From Dindo-Bot with MIT License | 5 votes |
def on_key_press(self, widget, event): if self.settings['EnableShortcuts']: # get keyname keyname = Gdk.keyval_name(event.keyval) ctrl = (event.state & Gdk.ModifierType.CONTROL_MASK) alt = (event.state & Gdk.ModifierType.MOD1_MASK) shift = (event.state & Gdk.ModifierType.SHIFT_MASK) # handle shortcuts for action in self.settings['Shortcuts']: value = self.settings['Shortcuts'][action] if value is not None: keys = value.split('+') if (len(keys) == 1 and keys[0] == keyname) or (len(keys) == 2 and ((keys[0] == 'Ctrl' and ctrl) or (keys[0] == 'Alt' and alt) or (keys[0] == 'Shift' and shift)) and keys[1] == keyname): # run actions if action == 'Start': self.start_button.emit('clicked') elif action == 'Pause': self.pause_button.emit('clicked') elif action == 'Stop': self.stop_button.emit('clicked') elif action == 'Minimize': self.iconify() elif action == 'Take Game Screenshot': self.take_screenshot_button.emit('clicked') elif action == 'Focus Game': self.focus_game() # stop event propagation return True # focus game if self.bot_thread and self.bot_thread.isAlive(): self.focus_game()
Example #10
Source File: clearine.py From clearine with MIT License | 5 votes |
def on_keypressed (self, widget, event): # handling an event when user press some key key = Gdk.keyval_name(event.keyval) if key in shortcuts.keys(): command = shortcuts[key] if command == "cancel": sys.exit() else: os.system(config["command-%s" % command])
Example #11
Source File: productgroup.py From amir with GNU General Public License v3.0 | 5 votes |
def on_key_release_event(self, sender, event): expand = 0 selection = self.treeview.get_selection() iter = selection.get_selected()[1] if iter != None: if Gdk.keyval_name(event.keyval) == "Left": if self.treeview.get_direction() != Gtk.TextDirection.LTR: expand = 1 else: expand = -1 if Gdk.keyval_name(event.keyval) == "Right": if self.treeview.get_direction() != Gtk.TextDirection.RTL: expand = 1 else: expand = -1 if expand == 1: if self.treestore.iter_has_child(iter): path = self.treestore.get_path(iter) self.treeview.expand_row(path, False) return elif expand == -1: path = self.treestore.get_path(iter) if self.treeview.row_expanded(path): self.treeview.collapse_row(path) else: parent = self.treestore.iter_parent(iter) if parent != None: path = self.treestore.get_path(parent) self.treeview.collapse_row(path) self.treeview.set_cursor(path, None, False) self.treeview.grab_focus() return
Example #12
Source File: subjects.py From amir with GNU General Public License v3.0 | 5 votes |
def on_key_release_event(self, sender, event): expand = 0 selection = self.treeview.get_selection() if selection.get_mode() == Gtk.SelectionMode.MULTIPLE: return iter = selection.get_selected()[1] if iter != None: if Gdk.keyval_name(event.keyval) == "Left": if self.treeview.get_direction() != Gtk.TextDirection.LTR: expand = 1 else: expand = -1 if Gdk.keyval_name(event.keyval) == "Right": if self.treeview.get_direction() != Gtk.TextDirection.RTL: expand = 1 else: expand = -1 if expand == 1: if self.treestore.iter_has_child(iter): path = self.treestore.get_path(iter) self.treeview.expand_row(path, False) return elif expand == -1: path = self.treestore.get_path(iter) if self.treeview.row_expanded(path): self.treeview.collapse_row(path) else: parent = self.treestore.iter_parent(iter) if parent != None: path = self.treestore.get_path(parent) self.treeview.collapse_row(path) self.treeview.set_cursor(path, None, False) self.treeview.grab_focus() return # if Gdk.keyval_name(event.keyval) == Ri:
Example #13
Source File: gnomecast.py From gnomecast with GNU General Public License v3.0 | 5 votes |
def on_key_press(self, widget, event, user_data=None): key = Gdk.keyval_name(event.keyval) ctrl = (event.state & Gdk.ModifierType.CONTROL_MASK) if key=='q' and ctrl: self.quit() return True return False
Example #14
Source File: monitor_gtk.py From imagebot with MIT License | 5 votes |
def on_key_pressed(self, event, data): (b, k) = data.get_keyval() key = Gdk.keyval_name(k)
Example #15
Source File: devdocs_desktop.py From devdocs-desktop with GNU General Public License v3.0 | 5 votes |
def on_header_search_entry_key_release_event(self, _widget, event): kname = Gdk.keyval_name(event.keyval) kcode = Gdk.keyval_to_unicode(event.keyval) if kname in ['Return', 'Down', 'Up']: self.run_javascript('sendKey', 'document', kcode) self.webview.grab_focus()
Example #16
Source File: main_window.py From ebook-viewer with GNU General Public License v3.0 | 5 votes |
def __on_keypress_viewer(self, wiget, data): """ Handles Left and Right arrow key presses :param wiget: :param data: """ if self.content_provider.status: key_value = Gdk.keyval_name(data.keyval) if key_value == "Right": self.load_chapter(self.content_provider.current_chapter + 1) elif key_value == "Left": self.load_chapter(self.content_provider.current_chapter - 1)
Example #17
Source File: __main__.py From razerCommander with GNU General Public License v3.0 | 5 votes |
def on_recordKeystrokeToggleBtn_key_press_event(self, toggle_btn, event): if toggle_btn.get_active(): keyname = Gdk.keyval_name(event.keyval) if keyname not in self.key_stroke_list: self.key_stroke_list.append(keyname) self.key_stroke_n += 1 else: self.key_stroke_n = 0 self.key_stroke_list = []
Example #18
Source File: widgets.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def do_key_press_event(self, event): # Keybindings for the treeview: # * expand all # / or \ collapse all # Right expand sub items # Left collapse sub items handled = True #~ print('KEY %s (%i)' % (Gdk.keyval_name(event.keyval), event.keyval)) if event.keyval in KEYVALS_ASTERISK: self.expand_all() elif event.keyval in KEYVALS_SLASH: self.collapse_all() elif event.keyval == KEYVAL_LEFT: model, paths = self.get_selection().get_selected_rows() if len(paths) == 1: self.collapse_row(paths[0]) elif event.keyval == KEYVAL_RIGHT: model, paths = self.get_selection().get_selected_rows() if len(paths) == 1: self.expand_row(paths[0], 0) else: handled = False if handled: return True else: return Gtk.TreeView.do_key_press_event(self, event)
Example #19
Source File: categories.py From rednotebook with GNU General Public License v2.0 | 5 votes |
def on_key_press_event(self, _view, event): keyname = Gdk.keyval_name(event.keyval) if keyname == "Delete": self._on_delete_entry_clicked(None) elif keyname == "F2": self._on_change_entry_clicked(None)
Example #20
Source File: menu_bar.py From RAFCON with Eclipse Public License 1.0 | 5 votes |
def on_escape_key_press_event_leave_full_screen(self, widget, event): keyname = Gdk.keyval_name(event.keyval) if keyname == "Escape" and 'fullscreen' in self.full_screen_window.get_window().get_state().value_nicks: self.view["full_screen"].set_active(False) return True
Example #21
Source File: asktext.py From textext with BSD 3-Clause "New" or "Revised" License | 5 votes |
def cb_key_press(self, widget, event, data=None): """ Handle keyboard shortcuts :param widget: :param event: :param data: :return: True, if a shortcut was recognized and handled """ ctrl_is_pressed = Gdk.ModifierType.CONTROL_MASK & event.state if Gdk.keyval_name(event.keyval) == 'Return' and ctrl_is_pressed: self._ok_button.clicked() return True # Show/ update Preview shortcut (CTRL+P) if Gdk.keyval_name(event.keyval) == 'p' and ctrl_is_pressed: self._preview_button.clicked() return True # Cancel dialog via shortcut if set by the user close_shortcut_value = self._gui_config.get("close_shortcut", self.DEFAULT_CLOSE_SHORTCUT) if (close_shortcut_value == 'Escape' and Gdk.keyval_name(event.keyval) == 'Escape') or \ (close_shortcut_value == 'CtrlQ' and Gdk.keyval_name(event.keyval) == 'q' and ctrl_is_pressed): self._cancel_button.clicked() return True return False
Example #22
Source File: player.py From kickoff-player with GNU General Public License v3.0 | 5 votes |
def on_window_main_key_release_event(self, _widget, event): if self.visible and Gdk.keyval_name(event.keyval) == 'F11': self.toggle_fullscreen()
Example #23
Source File: main_window.py From gtg with GNU General Public License v3.0 | 5 votes |
def on_tag_treeview_key_press_event(self, treeview, event): keyname = Gdk.keyval_name(event.keyval) is_shift_f10 = (keyname == "F10" and event.get_state() & Gdk.ModifierType.SHIFT_MASK) if is_shift_f10 or keyname == "Menu": selected_tags = self.get_selected_tags(nospecial=True) selected_search = self.get_selected_search() # FIXME thos two branches could be simplified (there is # no difference betweenn search and normal tag # popup menu for searches if selected_search is not None: self.tagpopup.set_tag(selected_search) self.tagpopup.popup(None, None, None, None, 0, event.time) elif len(selected_tags) > 0: # Then we are looking at single, normal tag rather than # the special 'All tags' or 'Tasks without tags'. We only # want to popup the menu for normal tags. selected_tag = self.req.get_tag(selected_tags[0]) self.tagpopup.set_tag(selected_tag) self.tagpopup.popup(None, None, None, None, 0, event.time) else: self.reset_cursor() return True if keyname == "Delete": self.on_delete_tag_activate(event) return True
Example #24
Source File: main_window.py From gtg with GNU General Public License v3.0 | 5 votes |
def on_task_treeview_key_press_event(self, treeview, event): keyname = Gdk.keyval_name(event.keyval) is_shift_f10 = (keyname == "F10" and event.get_state() & Gdk.ModifierType.SHIFT_MASK) if is_shift_f10 or keyname == "Menu": self.open_menu.popup_at_pointer(event) return True
Example #25
Source File: main_window.py From gtg with GNU General Public License v3.0 | 5 votes |
def on_closed_task_treeview_key_press_event(self, treeview, event): keyname = Gdk.keyval_name(event.keyval) is_shift_f10 = (keyname == "F10" and event.get_state() & Gdk.ModifierType.SHIFT_MASK) if is_shift_f10 or keyname == "Menu": self.closed_menu.popup_at_pointer(event) return True
Example #26
Source File: combobox_enhanced.py From gtg with GNU General Public License v3.0 | 5 votes |
def ifKeyPressedCallback(widget, key, callback): def keyPress(combobox, event): keyname = Gdk.keyval_name(event.keyval) if keyname == key: callback() widget.connect("key-press-event", keyPress)
Example #27
Source File: dataview_classes.py From innstereo with GNU General Public License v2.0 | 5 votes |
def on_key_pressed(self, treeview, event): """ Triggered when a key is pressed while the TreeView is active. If the Tab key was pressed the current value in the active cell is saved and the cursor jumps to the next cell and makes it editable. """ keyname = Gdk.keyval_name(event.keyval) path, col = treeview.get_cursor() columns = [c for c in treeview.get_columns() if c.get_visible()] colnum = columns.index(col) if keyname == "Tab" or keyname == "Esc": if colnum + 1 < len(columns): next_column = columns[colnum + 1] else: tmodel = treeview.get_model() titer = tmodel.iter_next(tmodel.get_iter(path)) if titer is None: lyr_type = self.lyr_obj.get_layer_type() self.add_feature(lyr_type, self.store) titer = tmodel.iter_next(tmodel.get_iter(path)) path = tmodel.get_path(titer) next_column = columns[0] if keyname == "Tab": GLib.timeout_add(50, treeview.set_cursor, path, next_column, True) elif keyname == "Escape": pass
Example #28
Source File: script.py From RAFCON with Eclipse Public License 1.0 | 5 votes |
def on_dialog_key_press(self, dialog, event, key_mapping, buttons): from gi.repository import Gdk key_name = Gdk.keyval_name(event.keyval).lower() for i, key_list in enumerate(key_mapping, 1): if i > len(buttons): break if not isinstance(key_list, list): key_list = [key_list] for desired_key in key_list: if desired_key.lower() == key_name: self.response(i)
Example #29
Source File: devdocs_desktop.py From devdocs-desktop with GNU General Public License v3.0 | 5 votes |
def on_finder_search_entry_key_release_event(self, _widget, event): kname = Gdk.keyval_name(event.keyval) if kname == 'Return': self.finder.search_next()
Example #30
Source File: overview.py From RAFCON with Eclipse Public License 1.0 | 5 votes |
def check_for_enter(self, entry, event): key_name = Gdk.keyval_name(event.keyval) if key_name in ["Return", "KP_Enter"]: self.change_name(entry.get_text())