Python gi.repository.Gdk.KEY_Delete() Examples

The following are 8 code examples of gi.repository.Gdk.KEY_Delete(). 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: managers.py    From king-phisher with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def signal_key_press_event(self, treeview, event):
		if event.type != Gdk.EventType.KEY_PRESS:
			return
		keyval = event.get_keyval()[1]
		if event.get_state() == Gdk.ModifierType.CONTROL_MASK:
			if keyval == Gdk.KEY_c and self.column_titles:
				gui_utilities.gtk_treeview_selection_to_clipboard(treeview, list(self.column_titles.values())[0])
		elif keyval == Gdk.KEY_F5 and self.cb_refresh:
			self.cb_refresh()
		elif keyval == Gdk.KEY_Delete:
			self._call_cb_delete() 
Example #2
Source File: directory.py    From king-phisher-plugins with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def signal_tv_key_press(self, _, event):
		if event.type != Gdk.EventType.KEY_PRESS:
			return
		keyval = event.get_keyval()[1]
		if keyval == Gdk.KEY_F2:
			self._rename_selection()
		elif keyval == Gdk.KEY_F5:
			self.refresh()
		elif keyval == Gdk.KEY_Delete:
			self._delete_selection() 
Example #3
Source File: filechooser.py    From hazzy with GNU General Public License v2.0 5 votes vote down vote up
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 #4
Source File: text_view.py    From Apostrophe with GNU General Public License v3.0 5 votes vote down vote up
def _on_key_press_event(self, _widget, event):
        if self.hemingway_mode:
            return event.keyval == Gdk.KEY_BackSpace or event.keyval == Gdk.KEY_Delete

        if event.state & Gdk.ModifierType.SHIFT_MASK == Gdk.ModifierType.SHIFT_MASK \
                and event.keyval == Gdk.KEY_ISO_Left_Tab:  # Capure Shift-Tab
            self._on_shift_tab()
            return True 
Example #5
Source File: totp_enroll.py    From python-eduvpn-client with GNU General Public License v3.0 5 votes vote down vote up
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 #6
Source File: yubi_enroll.py    From python-eduvpn-client with GNU General Public License v3.0 5 votes vote down vote up
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 #7
Source File: PlaceCompletion.py    From addons-source with GNU General Public License v2.0 4 votes vote down vote up
def button_press_event(self,obj,event):
        from gramps.gui.editors import EditPlace

        if (event.type == Gdk.EventType._2BUTTON_PRESS and
                event.button.button == 1):
            store, node = self.tree.get_selection().get_selected()
            if node:
                #only when non empty tree view you are here
                place_handle = store.get_value(node, 1)
                place = self.db.get_place_from_handle(place_handle)
                action = store.get_value(node,2)
                if action :
                    if action[1] != None :
                        place = self.group_set(place, action[0], action[1] )
                else :
                    #we are in a parent node, go over children nodes if present
                    index = 0
                    while store.iter_nth_child(node, index):
                        nodechild = store.iter_nth_child(node, index)
                        action = store.get_value(nodechild,2)
                        if action :
                            if action[1] != None :
                                place = self.group_set(place,
                                                action[0], action[1] )
                        index += 1

                try :
                    EditPlace(self.dbstate, self.uistate, self.track, place,
                           self.this_callback)
                except WindowActiveError :
                    pass

        if event.type == Gdk.EventType.KEY_PRESS and \
                event.keyval == Gdk.KEY_Delete:
            selection = self.tree.get_selection()
            store, node = selection.get_selected()
            if node :
                path = store.get_path(node)
                store.remove(node)
                # set selection to the next item
                selection.select_path(path)
                # if last of a path was deleted, the above gave no result
                # select next item if not empty list
                if not selection.path_is_selected(path):
                    row = path[0]-1
                    # test case for empty lists
                    if row >= 0:
                        selection.select_path((row,))

        if event.type == Gdk.EventType.KEY_PRESS and \
                event.keyval == Gdk.KEY_Tab:
            #call up google maps
            self.google() 
Example #8
Source File: widget_window.py    From hazzy with GNU General Public License v2.0 4 votes vote down vote up
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
#===================================