本文整理匯總了Python中gi.repository.Gdk.keyval_name方法的典型用法代碼示例。如果您正苦於以下問題:Python Gdk.keyval_name方法的具體用法?Python Gdk.keyval_name怎麽用?Python Gdk.keyval_name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gi.repository.Gdk
的用法示例。
在下文中一共展示了Gdk.keyval_name方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _gtk_key
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import keyval_name [as 別名]
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)
示例2: _key_press_event
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import keyval_name [as 別名]
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()
示例3: on_key_press
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import keyval_name [as 別名]
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
示例4: on_key_press_event
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import keyval_name [as 別名]
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
示例5: on_key_release_event
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import keyval_name [as 別名]
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
示例6: on_recordKeystrokeToggleBtn_key_release_event
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import keyval_name [as 別名]
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
示例7: do_key_press_event
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import keyval_name [as 別名]
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)
示例8: cb_key_press
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import keyval_name [as 別名]
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
示例9: on_window_main_key_release_event
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import keyval_name [as 別名]
def on_window_main_key_release_event(self, _widget, event):
if self.visible and Gdk.keyval_name(event.keyval) == 'F11':
self.toggle_fullscreen()
示例10: on_tag_treeview_key_press_event
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import keyval_name [as 別名]
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
示例11: on_task_treeview_key_press_event
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import keyval_name [as 別名]
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
示例12: on_closed_task_treeview_key_press_event
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import keyval_name [as 別名]
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
示例13: ifKeyPressedCallback
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import keyval_name [as 別名]
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)
示例14: on_key_pressed
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import keyval_name [as 別名]
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
示例15: on_dialog_key_press
# 需要導入模塊: from gi.repository import Gdk [as 別名]
# 或者: from gi.repository.Gdk import keyval_name [as 別名]
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)