当前位置: 首页>>代码示例>>Python>>正文


Python Gdk.KEY_Left方法代码示例

本文整理汇总了Python中gi.repository.Gdk.KEY_Left方法的典型用法代码示例。如果您正苦于以下问题:Python Gdk.KEY_Left方法的具体用法?Python Gdk.KEY_Left怎么用?Python Gdk.KEY_Left使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gi.repository.Gdk的用法示例。


在下文中一共展示了Gdk.KEY_Left方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_key_press

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import KEY_Left [as 别名]
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 
开发者ID:KanoComputing,项目名称:kano-settings,代码行数:21,代码来源:set_display.py

示例2: cursor_ctrl_arrow_rtl_fix

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import KEY_Left [as 别名]
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 
开发者ID:jamiemcg,项目名称:Remarkable,代码行数:20,代码来源:RemarkableWindow.py

示例3: on_arrow_left_pressed

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import KEY_Left [as 别名]
def on_arrow_left_pressed(self, widget, event):
        self.emulate_key(widget, None, Gdk.KEY_Left)

    # Right arrow 
开发者ID:KurtJacobson,项目名称:hazzy,代码行数:6,代码来源:keyboard.py

示例4: _parse_user_input

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import KEY_Left [as 别名]
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 
开发者ID:eduvpn,项目名称:python-eduvpn-client,代码行数:35,代码来源:totp_enroll.py

示例5: _parse_user_input

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import KEY_Left [as 别名]
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 
开发者ID:eduvpn,项目名称:python-eduvpn-client,代码行数:33,代码来源:yubi_enroll.py

示例6: on_key_press

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import KEY_Left [as 别名]
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
#=================================== 
开发者ID:KurtJacobson,项目名称:hazzy,代码行数:52,代码来源:widget_window.py

示例7: on_key_press_event

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import KEY_Left [as 别名]
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 
开发者ID:inguma,项目名称:bokken,代码行数:52,代码来源:xdot.py


注:本文中的gi.repository.Gdk.KEY_Left方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。