Python gi.repository.Gdk.KEY_Escape() Examples
The following are 26
code examples of gi.repository.Gdk.KEY_Escape().
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: keyboard.py From hazzy with GNU General Public License v2.0 | 5 votes |
def on_window_key_press_event(self, widget, event, data=None): kv = event.keyval if kv == Gdk.KEY_Escape: self.escape() # Close the keyboard elif kv == Gdk.KEY_Return or kv == Gdk.KEY_KP_Enter: self.enter(widget) else: # Pass other keypresses on to the entry widget try: self.entry.emit("key-press-event", event) except: pass # Escape action
Example #2
Source File: main_window.py From rednotebook with GNU General Public License v2.0 | 5 votes |
def _on_key_press_event(self, widget, event): # Exit fullscreen mode with ESC. if event.keyval == Gdk.KEY_Escape and self.is_fullscreen: self.toggle_fullscreen() # TRAY-ICON / CLOSE --------------------------------------------------------
Example #3
Source File: yubi_enroll.py From python-eduvpn-client with GNU General Public License v3.0 | 5 votes |
def _parse_user_input(builder, oauth, meta, config_dict, lets_connect): # type: (Gtk.builder, str, Metadata, dict, bool) -> None dialog = builder.get_object('yubi-enroll-dialog') code_entry = builder.get_object('yubi-code-entry') cancel_button = builder.get_object('yubi-cancel-button') submit_button = builder.get_object('yubi-submit-button') def callback(_, event): valid = chr(event.keyval).isdigit() logger.debug(u"user pressed {}, valid: {}".format(event.keyval, valid)) if event.keyval in (Gdk.KEY_Left, Gdk.KEY_Right, Gdk.KEY_BackSpace, Gdk.KEY_End, Gdk.KEY_Home, Gdk.KEY_Delete, Gdk.KEY_Return, Gdk.KEY_Escape): return False return event.keyval not in range(0x20, 0x7e) code_entry.connect("key-press-event", callback) cancel_button.set_sensitive(True) submit_button.set_sensitive(True) while True: response = dialog.run() if response == 0: key = code_entry.get_text() cancel_button.set_sensitive(False) submit_button.set_sensitive(False) thread_helper(lambda: _enroll(builder, oauth, meta, config_dict, key, lets_connect=lets_connect)) else: dialog.hide() break # background tread
Example #4
Source File: totp_enroll.py From python-eduvpn-client with GNU General Public License v3.0 | 5 votes |
def _parse_user_input(builder, oauth, meta, config_dict, lets_connect, secret=None): # type: (Gtk.builder, str, Metadata, dict, bool, str) -> None dialog = builder.get_object('totp-enroll-dialog') code_entry = builder.get_object('totp-code-entry') cancel_button = builder.get_object('totp-cancel-button') submit_button = builder.get_object('totp-submit-button') def callback(_, event): valid = chr(event.keyval).isdigit() logger.debug(u"user pressed {}, valid: {}".format(event.keyval, valid)) if event.keyval in (Gdk.KEY_Left, Gdk.KEY_Right, Gdk.KEY_BackSpace, Gdk.KEY_End, Gdk.KEY_Home, Gdk.KEY_Delete, Gdk.KEY_Return, Gdk.KEY_Escape): return False return not chr(event.keyval).isdigit() code_entry.connect("key-press-event", callback) code_entry.set_max_length(6) cancel_button.set_sensitive(True) submit_button.set_sensitive(True) while True: response = dialog.run() if response == 0: key = code_entry.get_text() cancel_button.set_sensitive(False) submit_button.set_sensitive(False) thread_helper(lambda: _enroll(builder, oauth, meta, config_dict, secret, key, lets_connect)) else: dialog.hide() break # background tread
Example #5
Source File: main.py From gagar with GNU General Public License v3.0 | 5 votes |
def on_key_pressed(self, val, char): if val == Gdk.KEY_Escape: self.client.disconnect() Gtk.main_quit() elif char == 'c': # reconnect to any server self.client.disconnect() address, token = find_server() self.client.connect(address, token) self.world_viewer.focus_player(self.client.player)
Example #6
Source File: auto_correct.py From Apostrophe with GNU General Public License v3.0 | 5 votes |
def key_pressed(self, _widget, event): if not self.bubble: return False if event.keyval in [Gdk.KEY_Escape, Gdk.KEY_BackSpace]: self.destroy_bubble() return False
Example #7
Source File: search_and_replace.py From Apostrophe with GNU General Public License v3.0 | 5 votes |
def key_pressed(self, _widget, event, _data=None): """hide the search and replace content box when ESC is pressed """ if event.keyval == Gdk.KEY_Escape: self.hide()
Example #8
Source File: entry_widgets.py From hazzy with GNU General Public License v2.0 | 5 votes |
def on_key_press(self, widget, event): if event.keyval == Gdk.KEY_Escape: self.set_text(self.previous_value) # Revert self.get_toplevel().set_focus(None)
Example #9
Source File: pref_widgets.py From hazzy with GNU General Public License v2.0 | 5 votes |
def on_key_press(self, widget, event, data=None): if event.keyval == Gdk.KEY_Escape: self.set_text(self.value) # Revert self.get_toplevel().set_focus(None)
Example #10
Source File: keyboard.py From hazzy with GNU General Public License v2.0 | 5 votes |
def on_entry_key_press(self, widget, event, data=None): kv = event.keyval if kv == Gdk.KEY_Escape: self.keyboard.hide() # Close the keyboard # ========================================================== # Show the keyboard # ==========================================================
Example #11
Source File: keyboard.py From hazzy with GNU General Public License v2.0 | 5 votes |
def escape(self): try: event = Gdk.Event(Gdk.KEY_PRESS) event.keyval = Gdk.KEY_Escape event.window = self.entry.window self.entry.event(event) self.entry.emit("key-press-event", event) except: pass self.entry.disconnect(self.focus_out_sig) self.entry.disconnect(self.key_press_sig) self.keyboard.hide()
Example #12
Source File: add.py From Authenticator with GNU General Public License v2.0 | 5 votes |
def _on_key_press(self, _, event): _, key_val = event.get_keyval() modifiers = event.get_state() if key_val == Gdk.KEY_Escape: self._on_quit() # CTRL + Q if modifiers == Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.MOD2_MASK: if key_val == Gdk.KEY_q: self._on_scan()
Example #13
Source File: filechooser.py From hazzy with GNU General Public License v2.0 | 5 votes |
def on_file_treeview_key_press_event(self, widget, event): kv = event.keyval # Events that don't need to know about modifiers if kv == Gdk.KEY_Escape: self.file_treeview.get_selection().unselect_all() self.builder.get_object('edit_button').set_sensitive(False) self.builder.get_object('cut_button').set_sensitive(False) self.builder.get_object('copy_button').set_sensitive(False) self.builder.get_object('delete_button').set_sensitive(False) return True elif kv == Gdk.KEY_Delete: self.delete_selected() return True elif kv == Gdk.KEY_F2: self.edit_selected() return True # Handle other events # Determine the actively pressed modifier modifier = event.get_state() & Gtk.accelerator_get_default_mod_mask() # Bool of Control or Shift modifier states control = modifier == Gdk.ModifierType.CONTROL_MASK shift = modifier == Gdk.ModifierType.SHIFT_MASK if control and kv == Gdk.KEY_c: return self.copy_selected() elif control and kv == Gdk.KEY_x: return self.cut_selected() elif control and kv == Gdk.KEY_v: return self.paste()
Example #14
Source File: alarm.py From coinprice-indicator with MIT License | 5 votes |
def _on_key_release(self, widget, ev, data=None): if ev.keyval == Gdk.KEY_Escape: self._close()
Example #15
Source File: plugin_selection.py From coinprice-indicator with MIT License | 5 votes |
def _on_key_release(self, widget, ev, data=None): if ev.keyval == Gdk.KEY_Escape: self._close()
Example #16
Source File: asset_selection.py From coinprice-indicator with MIT License | 5 votes |
def _on_key_release(self, widget, ev, data=None): if ev.keyval == Gdk.KEY_Escape: self._close()
Example #17
Source File: preferencesDialog.py From pychess with GNU General Public License v3.0 | 5 votes |
def initialize(widgets): """ :Description: Initialises the various tabs for each section of configurable artifacts """ global general_tab general_tab = GeneralTab(widgets) # All side panels can be show/hide from View menu now, so no need to do the same from preferences # We can re enable this after implementing install/uninstall functionality in the future... # PanelTab(widgets) uistuff.keepWindowSize("preferencesdialog", widgets["preferences_dialog"]) notebook = widgets["preferences_notebook"] def switch_page(widget, page, page_num): global hint_tab, theme_tab, sound_tab, save_tab if page_num == 1 and hint_tab is None: hint_tab = HintTab(widgets) elif page_num == 3 and theme_tab is None: theme_tab = ThemeTab(widgets) elif page_num == 4 and sound_tab is None: sound_tab = SoundTab(widgets) elif page_num == 5 and save_tab is None: save_tab = SaveTab(widgets) notebook.connect("switch_page", switch_page) def delete_event(widget, _): widgets["preferences_dialog"].hide() return True widgets["preferences_dialog"].connect("delete-event", delete_event) widgets["preferences_dialog"].connect( "key-press-event", lambda w, e: w.event(Gdk.Event(Gdk.EventType.DELETE)) if e.keyval == Gdk.KEY_Escape else None) # General initing
Example #18
Source File: findBar.py From Remarkable with MIT License | 5 votes |
def on_find_entry_key_press(self, widget, event): if event.keyval == Gdk.KEY_Return: self._find_text(backwards=self.is_searching_backwards) elif event.keyval == Gdk.KEY_Shift_R or event.keyval == Gdk.KEY_Shift_L: self.is_searching_backwards = True elif event.keyval == Gdk.KEY_Escape: self.hide()
Example #19
Source File: findBar.py From Remarkable with MIT License | 5 votes |
def on_find_bar_key_press(self, widget, event): if event.keyval == Gdk.KEY_Escape: self.hide()
Example #20
Source File: graphview.py From addons-source with GNU General Public License v2.0 | 5 votes |
def goto_other_btn_key_press_event(self, _widget, event): """ Handle 'Esc' key on bookmarks button to hide popup. """ key = event.keyval if event.keyval == Gdk.KEY_Escape: self.hide_bkmark_popover() elif key == Gdk.KEY_Down: self.bkmark_popover.grab_focus() return True
Example #21
Source File: search_widget.py From addons-source with GNU General Public License v2.0 | 5 votes |
def on_key_press_event(self, widget, event): """ Handle 'Esc' and 'Down' keys. """ key = event.keyval if key == Gdk.KEY_Escape: self.set_text("") self.emit('empty-search') elif key == Gdk.KEY_Down: self.emit('focus-to-result') return True
Example #22
Source File: edit.py From Authenticator with GNU General Public License v2.0 | 5 votes |
def _on_key_press(self, _, event): """ KeyPress event handler. """ _, key_val = event.get_keyval() if key_val == Gdk.KEY_Escape: self._on_quit()
Example #23
Source File: ICLogon.py From pychess with GNU General Public License v3.0 | 4 votes |
def __init__(self): self.connection = None self.helperconn = None self.connection_task = None self.helperconn_task = None self.lounge = None self.canceled = False self.cids = defaultdict(list) self.widgets = uistuff.GladeWidgets("fics_logon.glade") uistuff.keepWindowSize("fics_logon", self.widgets["fics_logon"], defaultPosition=uistuff.POSITION_GOLDEN) self.widgets["fics_logon"].connect( 'key-press-event', lambda w, e: e.keyval == Gdk.KEY_Escape and w.hide()) self.ics = "FICS" self.as_guest = self.widgets["logOnAsGuest"] self.widgets["logOnAsGuest"].connect("toggled", self.on_logOnAsGuest_toggled) def on_username_changed(widget): conf.set("usernameEntry", self.user_name_get_value(widget), section=self.ics) self.widgets["nameEntry"].connect("changed", on_username_changed) def on_password_changed(widget): conf.set("passwordEntry", widget.get_text(), section=self.ics) self.widgets["passEntry"].connect("changed", on_password_changed) def on_host_changed(widget): conf.set("hostEntry", self.host_get_value(widget), section=self.ics) self.widgets["hostEntry"].connect("changed", on_host_changed) self.widgets["timesealCheck"].connect("toggled", self.on_timeseal_toggled) self.infobar = Gtk.InfoBar() self.infobar.set_message_type(Gtk.MessageType.WARNING) # self.widgets["messagePanelHBox"].pack_start(self.infobar, # expand=False, fill=False) self.widgets["messagePanelHBox"].pack_start(self.infobar, False, False, 0) self.widgets["cancelButton"].connect("clicked", self.onCancel, True) self.widgets["stopButton"].connect("clicked", self.onCancel, False) self.widgets["createNewButton"].connect("clicked", self.onCreateNew) self.widgets["connectButton"].connect("clicked", self.onConnectClicked) self.widgets["progressbar"].set_show_text(True)
Example #24
Source File: enginesDialog.py From pychess with GNU General Public License v3.0 | 4 votes |
def run(widgets): global firstRun, engine_dialog if firstRun: # Display of the countries items = [] for iso in ISO3166_LIST: path = addDataPrefix("flags/%s.png" % iso.iso2) if not(iso.iso2 and os.path.isfile(path)): path = addDataPrefix("flags/unknown.png") items.append((get_pixbuf(path), iso.country)) uistuff.createCombo(widgets["engine_country_combo"], name="engine_country_combo", ellipsize_mode=Pango.EllipsizeMode.END) data = [(item[0], item[1]) for item in items] uistuff.updateCombo(widgets["engine_country_combo"], data) engine_dialog = EnginesDialog(widgets) def cancel_event(widget, with_confirmation, *args): # Confirm if the changes need to be saved modified = discoverer.hasChanged() if modified and with_confirmation: dialog = Gtk.MessageDialog(mainwindow(), type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.YES_NO) dialog.set_markup(_("You have unsaved changes. Do you want to save before leaving?")) response = dialog.run() dialog.destroy() # if response == Gtk.ResponseType.CANCEL: # return False if response == Gtk.ResponseType.NO: discoverer.restore() if response == Gtk.ResponseType.YES: discoverer.save() # Close the window widgets["manage_engines_dialog"].hide() return True def save_event(widget, *args): discoverer.save() widgets["manage_engines_dialog"].hide() return True widgets["manage_engines_dialog"].connect("delete-event", cancel_event, True) widgets["engine_cancel_button"].connect("clicked", cancel_event, False) widgets["engine_save_button"].connect("clicked", save_event) widgets["manage_engines_dialog"].connect( "key-press-event", lambda w, e: cancel_event(w, True) if e.keyval == Gdk.KEY_Escape else None) discoverer.backup() engine_dialog.widgets["enginebook"].set_current_page(0) widgets["manage_engines_dialog"].show() if not firstRun: engine_dialog.update_store() firstRun = False
Example #25
Source File: widget_window.py From hazzy with GNU General Public License v2.0 | 4 votes |
def on_key_press(self, widget, event): # Events that don't need to know about modifiers if event.keyval == Gdk.KEY_Escape: self.get_toplevel().set_focus(None) return True if event.keyval == Gdk.KEY_Delete: self.destroy() # Remove the widget return True if event.keyval == Gdk.KEY_Tab: # TODO Implement move focus to next widget pass # Get any active, but not pressed modifiers, like CapsLock and NumLock persistant_modifiers = Gtk.accelerator_get_default_mod_mask() # Determine the actively pressed modifier modifier = event.get_state() & persistant_modifiers # Bool of Control or Shift modifier states control = modifier == Gdk.ModifierType.CONTROL_MASK shift = modifier == Gdk.ModifierType.SHIFT_MASK # If neither Shift or Control we want to move the Widget if event.keyval == Gdk.KEY_Up and not (shift or control): self.parent.child_incremental_move(self, self.parent.Incremental.Move.UP) elif event.keyval == Gdk.KEY_Down and not (shift or control): self.parent.child_incremental_move(self, self.parent.Incremental.Move.DOWN) elif event.keyval == Gdk.KEY_Left and not (shift or control): self.parent.child_incremental_move(self, self.parent.Incremental.Move.LEFT) elif event.keyval == Gdk.KEY_Right and not (shift or control): self.parent.child_incremental_move(self, self.parent.Incremental.Move.RIGHT) # If either Shift or Control we want to resize the Widget elif event.keyval == Gdk.KEY_Up and (shift or control): self.parent.child_incremental_move(self, self.parent.Incremental.Resize.Height.SMALLER) elif event.keyval == Gdk.KEY_Down and (shift or control): self.parent.child_incremental_move(self, self.parent.Incremental.Resize.Height.BIGGER) elif event.keyval == Gdk.KEY_Left and (shift or control): self.parent.child_incremental_move(self, self.parent.Incremental.Resize.Width.SMALLER) elif event.keyval == Gdk.KEY_Right and (shift or control): self.parent.child_incremental_move(self, self.parent.Incremental.Resize.Width.BIGGER) # Indicate the event was handled return True #=================================== # Drag to Move / Resize #===================================
Example #26
Source File: xdot.py From bokken with GNU General Public License v2.0 | 4 votes |
def on_key_press_event(self, widget, event): if event.keyval == Gdk.KEY_Left: self.x -= self.POS_INCREMENT/self.zoom_ratio self.queue_draw() return True if event.keyval == Gdk.KEY_Right: self.x += self.POS_INCREMENT/self.zoom_ratio self.queue_draw() return True if event.keyval == Gdk.KEY_Up: self.y -= self.POS_INCREMENT/self.zoom_ratio self.queue_draw() return True if event.keyval == Gdk.KEY_Down: self.y += self.POS_INCREMENT/self.zoom_ratio self.queue_draw() return True if event.keyval in (Gdk.KEY_Page_Up, Gdk.KEY_plus, Gdk.KEY_equal, Gdk.KEY_KP_Add): self.zoom_image(self.zoom_ratio * self.ZOOM_INCREMENT) self.queue_draw() return True if event.keyval in (Gdk.KEY_Page_Down, Gdk.KEY_minus, Gdk.KEY_KP_Subtract): self.zoom_image(self.zoom_ratio / self.ZOOM_INCREMENT) self.queue_draw() return True if event.keyval == Gdk.KEY_Escape: self.drag_action.abort() self.drag_action = NullAction(self) return True if event.keyval == Gdk.KEY_r: self.reload() return True if event.keyval == Gdk.KEY_f: win = widget.get_toplevel() find_toolitem = win.uimanager.get_widget('/ToolBar/Find') textentry = find_toolitem.get_children() win.set_focus(textentry[0]) return True if event.keyval == Gdk.KEY_q: Gtk.main_quit() return True if event.keyval == Gdk.KEY_p: self.on_print() return True return False