def parse_keyevent_name(keyevent_name): ''' Parse keyevent name. @param keyevent_name: Key event name that return by function L{ I{get_keyevent_name} <get_keyevent_name>}. @return: Return tuple that contain key value and modifier mask, (keyval, modifier_mask). ''' keys = keyevent_name.split(" + ") if len(keys) == 1: keyval = int(gdk.keyval_from_name(keys[0])) modifier_mask = 0 else: keyval = int(gdk.keyval_from_name(keys[-1])) modifier_mask = 0 for modifier in keys[0:-1]: if modifier == "Ctrl": modifier_mask = modifier_mask | gdk.CONTROL_MASK elif modifier == "Super": modifier_mask = modifier_mask | gdk.SUPER_MASK elif modifier == "Hyper": modifier_mask = modifier_mask | gdk.HYPER_MASK elif modifier == "Alt": modifier_mask = modifier_mask | gdk.MOD1_MASK elif modifier == "Shift": modifier_mask = modifier_mask | gdk.SHIFT_MASK if gdk.keyval_is_upper(keyval) and len(get_key_name(keyval)) == 1: keyval = gdk.keyval_to_lower(keyval) modifier_mask = modifier_mask | gdk.SHIFT_MASK return (keyval, modifier_mask)
def parse_keyevent_name(keyevent_name): '''Parse keyevent name.''' keys = keyevent_name.split(" + ") if len(keys) == 1: keyval = int(gdk.keyval_from_name(keys[0])) modifier_mask = 0 else: keyval = int(gdk.keyval_from_name(keys[-1])) modifier_mask = 0 for modifier in keys[0:-1]: if modifier == "Ctrl": modifier_mask = modifier_mask | gdk.CONTROL_MASK elif modifier == "Super": modifier_mask = modifier_mask | gdk.SUPER_MASK elif modifier == "Hyper": modifier_mask = modifier_mask | gdk.HYPER_MASK elif modifier == "Alt": modifier_mask = modifier_mask | gdk.MOD1_MASK elif modifier == "Shift": modifier_mask = modifier_mask | gdk.SHIFT_MASK if gdk.keyval_is_upper(keyval) and len(get_key_name(keyval)) == 1: keyval = gdk.keyval_to_lower(keyval) modifier_mask = modifier_mask | gdk.SHIFT_MASK return (keyval, modifier_mask)
def OnKeyPress(self, wid, event=None): if (event.keyval == gdk.keyval_from_name("q") or event.keyval == gdk.keyval_from_name("Q")): gtk.mainquit() if (event.keyval == gdk.keyval_from_name('r') or event.keyval == gdk.keyval_from_name('R')): self.Reset() return gtk.TRUE elif (event.keyval == gdk.keyval_from_name('w') or event.keyval == gdk.keyval_from_name('W')): self.Wireframe() return gtk.TRUE elif (event.keyval == gdk.keyval_from_name('s') or event.keyval == gdk.keyval_from_name('S')): self.Surface() return gtk.TRUE elif (event.keyval == gdk.keyval_from_name('p') or event.keyval == gdk.keyval_from_name('P')): m = self.get_pointer() self.PickActor(m[0], m[1]) return gtk.TRUE else: return gtk.FALSE
def onKeyPress (self, widget, event): if event.keyval in map(keyval_from_name,("Return", "KP_Enter")): if not event.state & gtk.gdk.CONTROL_MASK: buffer = self.writeView.get_buffer() self.connection.client.run_command(buffer.props.text) #self.emit("messageTyped", buffer.props.text) self.addMessage(buffer.props.text, my=True) adj = self.sw.get_vadjustment() adj.set_value(adj.get_upper()) # Maintain variables backup, it will be restored to fics on quit for var in self.connection.lvm.variablesBackup: if buffer.props.text == "set %s" % var: if self.connection.lvm.variablesBackup[var] == 0: self.connection.lvm.variablesBackup[var] = 1 else: self.connection.lvm.variablesBackup[var] = 0 elif buffer.props.text in ("set %s 1" % var, "set %s on" % var, "set %s true" % var): self.connection.lvm.variablesBackup[var] = 1 elif buffer.props.text in ("set %s 0" % var, "set %s off" % var, "set %s false" % var): self.connection.lvm.variablesBackup[var] = 0 elif buffer.props.text.startswith("set %s " % var): parts = buffer.props.text.split() if len(parts) == 3 and parts[2]: self.connection.lvm.variablesBackup[var] = parts[2] # Maintain lists backup, it will be restored to fics on quit for list in self.connection.lvm.personalBackup: if buffer.props.text.startswith("addlist %s " % var) or buffer.props.text.startswith("+%s " % var): parts = buffer.props.text.split() if len(parts) == 3 and parts[2]: self.connection.lvm.personalBackup[var].add(parts[2]) if buffer.props.text.startswith("sublist %s " % var) or buffer.props.text.startswith("-%s " % var): parts = buffer.props.text.split() if len(parts) == 3 and parts[2]: self.connection.lvm.personalBackup[var].discard(parts[2]) self.history.append(buffer.props.text) buffer.props.text = "" self.pos = len(self.history) return True elif event.keyval == keyval_from_name("Up"): if self.pos > 0: buffer = self.writeView.get_buffer() self.pos -= 1 buffer.props.text = self.history[self.pos] widget.grab_focus() return True elif event.keyval == keyval_from_name("Down"): buffer = self.writeView.get_buffer() if self.pos == len(self.history)-1: self.pos += 1 buffer.props.text = "" elif self.pos < len(self.history): self.pos += 1 buffer.props.text = self.history[self.pos] widget.grab_focus() return True
def on_entry_accelerator_key_press(self, entry, event): source_view = self['source_view_snippet'] if event.keyval == gdk.keyval_from_name('Escape'): # Reset entry.set_text(self.snippet.accelerator_display()) self.tree_view.grab_focus() return True elif event.keyval == gdk.keyval_from_name('Delete') or \ event.keyval == gdk.keyval_from_name('BackSpace'): # Remove the accelerator entry.set_text('') self.snippet['accelerator'] = '' self.tree_view.grab_focus() self.snippet_changed() return True elif Library().valid_accelerator(event.keyval, event.state): # New accelerator self.set_accelerator(event.keyval, \ event.state & gtk.accelerator_get_default_mod_mask()) entry.set_text(self.snippet.accelerator_display()) self.snippet_changed() self.tree_view.grab_focus() else: return True
def set_mac_accelerators(self): # Set up accelerators suitable for the Mac. # Ctrl-Up and Ctrl-Down are taken by the window manager, so we use # Ctrl-PgUp and Ctrl-PgDn. # We want it to be easy to switch, so both sets of keys are always # active, but only one, most suitable for each platform, is displayed # in the menu. accel_group = gtk.accel_groups_from_object(self.window_main)[0] menu_up = self.menuitem_history_up UP = gdk.keyval_from_name('Up') PGUP = gdk.keyval_from_name('Prior') menu_dn = self.menuitem_history_down DN = gdk.keyval_from_name('Down') PGDN = gdk.keyval_from_name('Next') if sys.platform != 'darwin': menu_up.add_accelerator('activate', accel_group, PGUP, gdk.CONTROL_MASK, 0) menu_dn.add_accelerator('activate', accel_group, PGDN, gdk.CONTROL_MASK, 0) else: menu_up.remove_accelerator(accel_group, UP, gdk.CONTROL_MASK) menu_up.add_accelerator('activate', accel_group, PGUP, gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE) menu_up.add_accelerator('activate', accel_group, UP, gdk.CONTROL_MASK, 0) menu_dn.remove_accelerator(accel_group, DN, gdk.CONTROL_MASK) menu_dn.add_accelerator('activate', accel_group, PGDN, gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE) menu_dn.add_accelerator('activate', accel_group, DN, gdk.CONTROL_MASK, 0)
def on_find_key_released(self, widget, event): if event.keyval == gdk.keyval_from_name("G") and \ event.state & gtk.gdk.SHIFT_MASK and \ event.state & gtk.gdk.CONTROL_MASK: self.on_find_response("find_prev") widget.stop_emission("key-release-event") elif event.keyval == gdk.keyval_from_name("g") and \ event.state & gtk.gdk.CONTROL_MASK: self.on_find_response("find_next") widget.stop_emission("key-release-event")
def findWithDeadKey(self, keysym): name = gdk.keyval_name(keysym) # @UndefinedVariable for deadName in DEAD_KEYS: if name.endswith(deadName): keyName = name[:-len(deadName)] deadName = {'ring': 'abovering', 'schwa': 'small_schwa', 'SCHWA': 'capital_schwa'}.get(deadName, deadName) deadName = 'dead_' + deadName keyKeysym = gdk.keyval_from_name(keyName) # @UndefinedVariable deadSym = gdk.keyval_from_name(deadName) # @UndefinedVariable return keyKeysym, deadSym return None
def get_keycode(key, display=None): '''Helper function to get a keycode from raw key name''' if not display: display = get_display() keysym = keyval_from_name(key) keycode = display.keysym_to_keycode(keysym) return keycode
def on_key_released(self, widget, event): """Process delete key""" if event.keyval == gdk.keyval_from_name("Delete") and \ not self.editing: self.on_delete_node() self.stop_emission("key-release-event")
def key_up(self, keyname): """Return true if the specified key is released. It returns true only at the instance of releasing the key. """ key = gdk.keyval_from_name(keyname) return not (key in self.__keymap) and (key in self.__next_keymap)
def key_down(self, keyname): """Return true if the specified key is pressed. It returns true only at the instance of pressing the key. """ key = gdk.keyval_from_name(keyname) return (key in self.__keymap) and not (key in self.__next_keymap)
def OnKeyPress(self, wid, event=None): if event.keyval == gdk.keyval_from_name("i") or event.keyval == gdk.keyval_from_name("I"): xyz = self.get_cursor_position_world() if xyz is None: return marker = Marker(xyz=xyz, rgb=EventHandler().get_default_color()) EventHandler().add_marker(marker) return True elif event.keyval == gdk.keyval_from_name("r") or event.keyval == gdk.keyval_from_name("R"): self.set_camera(self.resetCamera) return True return MarkerWindowInteractor.OnKeyPress(self, wid, event)
def OnKeyPress(self, wid, event=None): if (event.keyval == gdk.keyval_from_name("i") or event.keyval == gdk.keyval_from_name("I")): xyz = self.get_cursor_position_world() if xyz is None: return marker = Marker(xyz=xyz, rgb=EventHandler().get_default_color()) EventHandler().add_marker(marker) return True elif (event.keyval == gdk.keyval_from_name("r") or event.keyval == gdk.keyval_from_name("R")): self.set_camera(self.resetCamera) return True return MarkerWindowInteractor.OnKeyPress(self, wid, event)
def OnKeyPress(self, wid, event=None): if event.keyval == gdk.keyval_from_name("q") or event.keyval == gdk.keyval_from_name("Q"): gtk.main_quit() if event.keyval == gdk.keyval_from_name("r") or event.keyval == gdk.keyval_from_name("R"): self.Reset() return True elif event.keyval == gdk.keyval_from_name("w") or event.keyval == gdk.keyval_from_name("W"): self.Wireframe() return True elif event.keyval == gdk.keyval_from_name("s") or event.keyval == gdk.keyval_from_name("S"): self.Surface() return True elif event.keyval == gdk.keyval_from_name("p") or event.keyval == gdk.keyval_from_name("P"): m = self.get_pointer() self.PickActor(m[0], m[1]) return True else: return False
def __get_shortcut_from_buttons(self): modifiers = [] keycode = self.__keycode_entry.get_text() if gdk.keyval_from_name(keycode) == 0: return None for name, button, mask in self.__modifier_buttons: if button.get_active(): modifiers.append(name) if keycode.startswith("_"): keycode = keycode[1:] keys = modifiers + [keycode] shortcut = "+".join(keys) return shortcut
def on_key_released(self, widget, event): """Callback for key release events""" # no special processing while editing nodes if self.editing: return if event.keyval == gdk.keyval_from_name("Delete"): # capture node deletes self.stop_emission("key-release-event") self.on_delete_node() elif event.keyval == gdk.keyval_from_name("BackSpace") and \ event.state & gdk.CONTROL_MASK: # capture goto parent node self.stop_emission("key-release-event") self.emit("goto-parent-node") elif event.keyval == gdk.keyval_from_name("Return") and \ event.state & gdk.CONTROL_MASK: # capture goto node self.stop_emission("key-release-event") self.emit("goto-node", None)
def on_tree_view_snippets_key_press(self, treeview, event): if event.keyval == gdk.keyval_from_name('Delete'): self.on_button_remove_snippet_clicked(None) return True
LINE_MODE_FREEHAND = "mypaint-line-mode-freehand" LINE_MODE_STRAIGHT = "mypaint-line-mode-straight" LINE_MODE_SEQUENCE = "mypaint-line-mode-sequence" LINE_MODE_ELLIPSE = "mypaint-line-mode-ellipse" _stock_items = [ # Tool windows. No trailing ellipses on these since none of them require # further input before they can do anything: see section 4.3.2.1 of the the # GNOME Human Interface Guidelines version 3.0. (TOOL_BRUSH, _("Brush List Editor"), gdk.SHIFT_MASK, ord("b"), None), (TOOL_COLOR_SELECTOR, _("Color Triangle"), 0, ord("g"), None), (TOOL_COLOR_SAMPLER, _("Color Sampler"), 0, ord("t"), None), (TOOL_SCRATCHPAD, _("Scratchpad"), gdk.SHIFT_MASK, ord("s"), None), (TOOL_LAYERS, _("Layers"), 0, ord("l"), None), (ROTATE_LEFT, _("Rotate Counterclockwise"), gdk.CONTROL_MASK, gdk.keyval_from_name("Left"), None), (ROTATE_RIGHT, _("Rotate Clockwise"), gdk.CONTROL_MASK, gdk.keyval_from_name("Right"), None), (SYMMETRY, _("Symmetrical Painting"), gdk.SHIFT_MASK, ord("i"), None), (MIRROR_HORIZONTAL, _("Mirror Horizontal"), 0, ord("i"), None), (MIRROR_VERTICAL, _("Mirror Vertical"), 0, ord("u"), None), (BRUSH_BLEND_MODES, _("Blend Mode"), 0, 0, None), (BRUSH_BLEND_MODE_NORMAL, _("Normal"), 0, ord("n"), None), (BRUSH_BLEND_MODE_ERASER, _("Eraser"), 0, ord("e"), None), (BRUSH_BLEND_MODE_ALPHA_LOCK, _("Lock Alpha Channel"), gdk.SHIFT_MASK, ord("l"), None), (BRUSH_BLEND_MODE_COLORIZE, _("Colorize"), 0, ord("k"), None), (BRUSH_MODIFIERS_ACTIVE, _("Brush Modifiers Active"), 0, 0, None), (BRUSH_MODIFIERS_INACTIVE, _("Brush Modifiers Inactive"), 0, 0, None), (LINE_MODES, _("Line Mode"), 0, 0, None), (LINE_MODE_FREEHAND, _("Freehand"), 0, 0, None), (LINE_MODE_STRAIGHT, _("Straight/Curved Lines"), 0, 0, None), (LINE_MODE_SEQUENCE, _("Sequence of Lines"), 0, 0, None),
def addShortcut(accelGroup, widget, shortcut, callback, *args): """ Adds a shortcut identified by a string to the widget and sets the callback to the shortcut. The shortcut string looks like this: <ctrl><shift>2 => (l/r)-CTRL + (l/r)-shift + 2 There are max. 3 modifier (ctrl/shift/alt/...) allowed. """ match = shortExp.match(shortcut) if not match: logging.error("addShortcut: No pattern match for %s" % (shortcut)) return None vGroups = [g for g in match.groups() if g] if not vGroups: logging.error("addShortcut: No filled groups for %s" % (shortcut)) return None mask = 0 for group in vGroups[:-1]: if group == "<ctrl>": mask |= CONTROL_MASK if group == "<shift>": mask |= SHIFT_MASK if group == "<alt>": mask |= MOD1_MASK key = vGroups[-1] if len(key) > 1: keyval = keyval_from_name(key) if not keyval: logging.error("addShortcut: Too much chars for (%s)." % (key)) return None else: keyval = ord(key) # name like shortCut_ctrl_shift_2 signame = "shortCut_"+"_".join([i.strip("<>") for i in vGroups]) if not signal_lookup(signame, widget): signal_new(signame, widget, SIGNAL_ACTION, None, ()) widget.add_accelerator( signame, accelGroup, keyval, mask, ACCEL_VISIBLE) handler = widget.connect(signame, callback, shortcut, *args) if not regmap.has_key(accelGroup): regmap[accelGroup] = {} if not regmap[accelGroup].has_key(widget): regmap[accelGroup][widget]=[ (handler,vGroups,keyval,mask) ] else: regmap[accelGroup][widget].append( (handler,vGroups,keyval,mask) ) return handler
def on_tree_view_key_press(self, entry, event): if event.keyval == gdk.keyval_from_name('Escape'): self.destroy() return True return False
from editperson import EditPerson from displaytabs import (EmbeddedList, EventEmbedList, CitationEmbedList, FamilyAttrEmbedList, NoteTab, GalleryTab, FamilyLdsEmbedList, ChildModel) from gui.widgets import (PrivacyButton, MonitoredEntry, MonitoredDataType, MonitoredTagList) from gen.plug import CATEGORY_QR_FAMILY from QuestionDialog import (ErrorDialog, RunDatabaseRepair, WarningDialog, MessageHideDialog) from gen.utils import get_birth_or_fallback, get_death_or_fallback from gui.selectors import SelectorFactory from Utils import preset_name SelectPerson = SelectorFactory('Person') _RETURN = gdk.keyval_from_name("Return") _KP_ENTER = gdk.keyval_from_name("KP_Enter") _LEFT_BUTTON = 1 _RIGHT_BUTTON = 3 class ChildEmbedList(EmbeddedList): """ The child embed list is specific to the Edit Family dialog, so it is contained here instead of in displaytabs. """ _HANDLE_COL = 13 _DND_TYPE = DdTargets.CHILDREF _DND_EXTRA = DdTargets.PERSON_LINK
def __init__(self): gtk.Frame.__init__(self)#, type=gtk.WindowType.TOPLEVEL) print "here" #self.set_default_size(500, 500) #self.connect('destroy', lambda x: gtk.main_quit()) #self.set_title('OpenStreetMap GPS Mapper') self.vbox = gtk.VBox(False, 0) self.add(self.vbox) if 0: self.osm = DummyMapNoGpsPoint() else: self.osm = osmgpsmap.GpsMap(map_source=osmgpsmap.SOURCE_VIRTUAL_EARTH_SATELLITE) self.osm.layer_add( osmgpsmap.GpsMapOsd( show_dpad=True, show_zoom=True, show_crosshair=True) ) self.osm.layer_add( DummyLayer() ) #print dir(self.osm) #self.osm.map_source = osmgpsmap.SOURCE_GOOGLE_SATELLITE self.last_image = None self.osm.connect('button_press_event', self.on_button_press) self.osm.connect('button_release_event', self.on_button_release) #connect keyboard shortcuts self.osm.set_keyboard_shortcut(osmgpsmap.KEY_FULLSCREEN, gdk.keyval_from_name("F11")) self.osm.set_keyboard_shortcut(osmgpsmap.KEY_UP, gdk.keyval_from_name("Up")) self.osm.set_keyboard_shortcut(osmgpsmap.KEY_DOWN, gdk.keyval_from_name("Down")) self.osm.set_keyboard_shortcut(osmgpsmap.KEY_LEFT, gdk.keyval_from_name("Left")) self.osm.set_keyboard_shortcut(osmgpsmap.KEY_RIGHT, gdk.keyval_from_name("Right")) #connect to tooltip self.osm.props.has_tooltip = True self.osm.connect("query-tooltip", self.on_query_tooltip) self.latlon_entry = gtk.Entry() zoom_in_button = gtk.Button(stock=gtk.STOCK_ZOOM_IN) zoom_in_button.connect('clicked', self.zoom_in_clicked) zoom_out_button = gtk.Button(stock=gtk.STOCK_ZOOM_OUT) zoom_out_button.connect('clicked', self.zoom_out_clicked) home_button = gtk.Button(stock=gtk.STOCK_HOME) home_button.connect('clicked', self.home_clicked) cache_button = gtk.Button('Cache') cache_button.connect('clicked', self.cache_clicked) self.vbox.pack_start(self.osm, True, True, 0) hbox = gtk.HBox(False, 0) hbox.pack_start(zoom_in_button, False, True, 0) hbox.pack_start(zoom_out_button, False, True, 0) hbox.pack_start(home_button, False, True, 0) hbox.pack_start(cache_button, False, True, 0) #add ability to test custom map URIs ex = gtk.Expander(label="<b>Map Repository URI</b>") ex.props.use_markup = True vb = gtk.VBox() self.repouri_entry = gtk.Entry() self.repouri_entry.set_text(self.osm.props.repo_uri) self.image_format_entry = gtk.Entry() self.image_format_entry.set_text(self.osm.props.image_format) lbl = gtk.Label( """ Enter an repository URL to fetch map tiles from in the box below. Special metacharacters may be included in this url <i>Metacharacters:</i> \t#X\tMax X location \t#Y\tMax Y location \t#Z\tMap zoom (0 = min zoom, fully zoomed out) \t#S\tInverse zoom (max-zoom - #Z) \t#Q\tQuadtree encoded tile (qrts) \t#W\tQuadtree encoded tile (1234) \t#U\tEncoding not implemeted \t#R\tRandom integer, 0-4""") #gmaps http://maps.googleapis.com/maps/api/staticmap?center=#X,#Y&zoom=#Z&size=200x200&sensor=false lbl.props.xalign = 0 lbl.props.use_markup = True lbl.props.wrap = True ex.add(vb) vb.pack_start(lbl, False, True, 0) hb = gtk.HBox() hb.pack_start(gtk.Label("URI: "), False, True, 0) hb.pack_start(self.repouri_entry, True, True, 0) vb.pack_start(hb, False, True, 0) hb = gtk.HBox() hb.pack_start(gtk.Label("Image Format: "), False, True, 0) hb.pack_start(self.image_format_entry, True, True, 0) vb.pack_start(hb, False, True, 0) gobtn = gtk.Button("Load Map URI") gobtn.connect("clicked", self.load_map_clicked) vb.pack_start(gobtn, False, True, 0) self.show_tooltips = False cb = gtk.CheckButton("Show Location in Tooltips") cb.props.active = self.show_tooltips cb.connect("toggled", self.on_show_tooltips_toggled) self.vbox.pack_end(cb, False, True, 0) cb = gtk.CheckButton("Disable Cache") cb.props.active = False cb.connect("toggled", self.disable_cache_toggled) self.vbox.pack_end(cb, False, True, 0) self.vbox.pack_end(ex, False, True, 0) self.vbox.pack_end(self.latlon_entry, False, True, 0) self.vbox.pack_end(hbox, False, True, 0) gobject.timeout_add(500, self.print_tiles)
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. ############################################################################### from gtk.gdk import keyval_from_name from view.keymap import Keymap RALT_MASK = 'mod5-mask' LALT_MASK = 'mod1-mask' AND = lambda *a: "(%s) and (%s)" % a OR = lambda *a: "(%s) or (%s)" % a KEY_PRESS_VAL = lambda k: "(evt_type=='key-press') and (evt.keyval==%u)" % k KEY_RELEASE_VAL = lambda k: "(evt_type=='key-release') and (evt.keyval==%u)" % k KEY_PRESS_NAME = lambda s: KEY_PRESS_VAL(keyval_from_name(s)) KEY_RELEASE_NAME = lambda s: KEY_RELEASE_VAL(keyval_from_name(s)) cursor_enter = "evt_type=='enter-notify'" cursor_leave = "evt_type=='leave-notify'" cursor_motion = "evt_type=='motion-notify'" scroll_up = "(evt_type=='scroll') and (evt.direction.value_nick=='up')" scroll_down = "(evt_type=='scroll') and (evt.direction.value_nick=='down')" button_press = "evt_type=='button-press'" button_release = "evt_type=='button-release'" button1 = "evt.button==1" button2 = "evt.button==2" button3 = "evt.button==3" button1_mod = "'button1-mask' in evt.state.value_nicks" button2_mod = "'button2-mask' in evt.state.value_nicks" button3_mod = "'button3-mask' in evt.state.value_nicks"
def name2unicode(name): keysym = gdk.keyval_from_name(name) # @UndefinedVariable return gdk.keyval_to_unicode(keysym) # @UndefinedVariable
def name2keysym(name): return gdk.keyval_from_name(name) # @UndefinedVariable
def key_press_event(self, widget, event): from gtk.gdk import keyval_from_name,keyval_name if event.keyval in (keyval_from_name('Return'),keyval_from_name('KP_Enter')): self.callback(widget)