Python gi.repository.Gdk.KEY_Right() Examples

The following are 7 code examples of gi.repository.Gdk.KEY_Right(). 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: set_display.py    From kano-settings with GNU General Public License v2.0 6 votes vote down vote up
def on_key_press(self, widget, event):
        # Right arrow (65363)
        if not hasattr(event, 'keyval') or event.keyval == Gdk.KEY_Right:
            self.overscan_values['top'] += 1
            self.overscan_values['bottom'] += 1
            self.overscan_values['left'] += 1
            self.overscan_values['right'] += 1
            set_overscan_status(self.overscan_values)
            self.t_scale.set_value(self.overscan_values['top'])
            return
        # Left arrow (65361)
        if not hasattr(event, 'keyval') or event.keyval == Gdk.KEY_Left:
            self.overscan_values['top'] -= 1
            self.overscan_values['bottom'] -= 1
            self.overscan_values['left'] -= 1
            self.overscan_values['right'] -= 1
            set_overscan_status(self.overscan_values)
            self.t_scale.set_value(self.overscan_values['top'])
            return 
Example #2
Source File: RemarkableWindow.py    From Remarkable with MIT License 6 votes vote down vote up
def cursor_ctrl_arrow_rtl_fix(self, widget, event):
        if event.keyval in [Gdk.KEY_Left, Gdk.KEY_Right]:
            if event.state & Gdk.ModifierType.CONTROL_MASK:
                is_rtl = self.remarkable_settings['rtl']

                dirs = {
                    Gdk.KEY_Left: is_rtl and 1 or -1,
                    Gdk.KEY_Right: is_rtl and -1 or 1,
                }

                widget.emit('move-cursor',
                            Gtk.MovementStep.WORDS,
                            dirs[event.keyval],
                            event.state & Gdk.ModifierType.SHIFT_MASK != 0)

                return True

        return False 
Example #3
Source File: keyboard.py    From hazzy with GNU General Public License v2.0 5 votes vote down vote up
def on_arrow_right_pressed(self, widget, event):
        self.emulate_key(widget, None, Gdk.KEY_Right)

    # Up Arrow 
Example #4
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 #5
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 #6
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
#=================================== 
Example #7
Source File: xdot.py    From bokken with GNU General Public License v2.0 4 votes vote down vote up
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