本文整理汇总了Python中pygame.K_BACKSPACE属性的典型用法代码示例。如果您正苦于以下问题:Python pygame.K_BACKSPACE属性的具体用法?Python pygame.K_BACKSPACE怎么用?Python pygame.K_BACKSPACE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pygame
的用法示例。
在下文中一共展示了pygame.K_BACKSPACE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _map_keys
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_BACKSPACE [as 别名]
def _map_keys(self):
key_map = self.io.key_map
key_map[imgui.KEY_TAB] = pygame.K_TAB
key_map[imgui.KEY_LEFT_ARROW] = pygame.K_LEFT
key_map[imgui.KEY_RIGHT_ARROW] = pygame.K_RIGHT
key_map[imgui.KEY_UP_ARROW] = pygame.K_UP
key_map[imgui.KEY_DOWN_ARROW] = pygame.K_DOWN
key_map[imgui.KEY_PAGE_UP] = pygame.K_PAGEUP
key_map[imgui.KEY_PAGE_DOWN] = pygame.K_PAGEDOWN
key_map[imgui.KEY_HOME] = pygame.K_HOME
key_map[imgui.KEY_END] = pygame.K_END
key_map[imgui.KEY_DELETE] = pygame.K_DELETE
key_map[imgui.KEY_BACKSPACE] = pygame.K_BACKSPACE
key_map[imgui.KEY_ENTER] = pygame.K_RETURN
key_map[imgui.KEY_ESCAPE] = pygame.K_ESCAPE
key_map[imgui.KEY_A] = pygame.K_a
key_map[imgui.KEY_C] = pygame.K_c
key_map[imgui.KEY_V] = pygame.K_v
key_map[imgui.KEY_X] = pygame.K_x
key_map[imgui.KEY_Y] = pygame.K_y
key_map[imgui.KEY_Z] = pygame.K_z
示例2: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_BACKSPACE [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if not self.show_msg:
if event.type == pygame.KEYDOWN and event.key != pygame.K_RETURN:
lhv = len(self.home_square.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.home_square.value = self.home_square.value[0:lhv - 1]
else:
char = event.unicode
if char in self.digits:
if len(char) > 0 and lhv < self.max_len:
self.home_square.value += char
else:
self.home_square.value = char
self.home_square.update_me = True
self.mainloop.redraw_needed[0] = True
示例3: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_BACKSPACE [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if not self.show_msg:
if event.type == pygame.KEYDOWN and event.key != pygame.K_RETURN:
lhv = len(self.home_square.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.home_square.value = self.home_square.value[0:lhv - 1]
else:
char = event.unicode
if char in self.digits:
if len(char) > 0 and lhv < 2:
self.home_square.value += char
else:
self.home_square.value = char
self.home_square.update_me = True
self.mainloop.redraw_needed[0] = True
示例4: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_BACKSPACE [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if not self.show_msg:
if event.type == pygame.KEYDOWN and (event.key != pygame.K_RETURN and event.key != pygame.K_KP_ENTER):
lhv = len(self.home_square.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.home_square.value = self.home_square.value[0:lhv - 1]
else:
char = event.unicode
if len(char) > 0 and lhv < 3 and char in self.digits:
self.home_square.value += char
self.home_square.update_me = True
self.mainloop.redraw_needed[0] = True
self.auto_check_reset()
elif event.type == pygame.KEYDOWN and (event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER):
self.check_result()
if event.type == pygame.MOUSEBUTTONDOWN:
self.auto_check_reset()
示例5: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_BACKSPACE [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if not self.show_msg:
if event.type == pygame.KEYDOWN and (event.key != pygame.K_RETURN and event.key != pygame.K_KP_ENTER):
lhv = len(self.home_square.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.home_square.value = self.home_square.value[0:lhv - 1]
else:
char = event.unicode
if len(char) > 0 and lhv < self.sollen and char in self.digits:
self.home_square.value += char
self.home_square.update_me = True
self.mainloop.redraw_needed[0] = True
self.auto_check_reset()
elif event.type == pygame.KEYDOWN and (event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER):
self.check_result()
if event.type == pygame.MOUSEBUTTONDOWN:
self.auto_check_reset()
示例6: handle_event
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_BACKSPACE [as 别名]
def handle_event(self, event):
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_BACKSPACE:
self.reset()
if event.key == pygame.K_SPACE:
self.speed_y = -20
if event.key == pygame.K_LEFT:
self.speed_x -= 10
elif event.key == pygame.K_RIGHT:
self.speed_x += 10
elif event.key == pygame.K_DOWN:
self.gravity += 10
elif event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT:
self.speed_x -= -10
elif event.key == pygame.K_RIGHT:
self.speed_x += -10
elif event.key == pygame.K_DOWN:
self.gravity += -10
示例7: check_keypress
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_BACKSPACE [as 别名]
def check_keypress():
try:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_q or event.key == pygame.K_a or event.key == pygame.K_KP_DIVIDE or event.key == pygame.K_BACKSPACE:
logger.debug("Keypress 'a' or 'q' or 'backspace' or 'keypad /' detected.")
return "end_event"
if event.key == pygame.K_n or event.key == pygame.K_SPACE or event.key == pygame.K_KP_PLUS:
logger.debug("Keypress 'n' or 'space' or 'keypad +' detected.")
return "next_event"
if event.key == pygame.K_r or event.key == pygame.K_KP_PERIOD or event.key == pygame.K_COMMA:
logger.debug("Keypress 'r' or ',' or 'keypad .' detected")
return "resume_rotation"
if event.key == pygame.K_p or event.key == pygame.K_KP_MULTIPLY:
logger.debug("Keypress 'p' or 'keypad *' detected")
return "pause_rotation"
for numeric_key_counter, key in enumerate([pygame.K_F1,pygame.K_F2,pygame.K_F3,pygame.K_F4,pygame.K_F5,pygame.K_F6,pygame.K_F7,pygame.K_F8,pygame.K_F9,pygame.K_F10,pygame.K_F11,pygame.K_F12]):
if event.key == key:
logger.debug("Keypress 'F" + str(numeric_key_counter + 1) + "' detected")
return numeric_key_counter
for numeric_key_counter, key in enumerate([pygame.K_KP0,pygame.K_KP1,pygame.K_KP2,pygame.K_KP3,pygame.K_KP4,pygame.K_KP5,pygame.K_KP6,pygame.K_KP7,pygame.K_KP8,pygame.K_KP9]):
if event.key == key:
logger.debug("Keypress 'keypad " + str(numeric_key_counter + 1) + "' detected")
return numeric_key_counter
else:
return None
except pygame.error as e:
logger.debug("Exception " + repr(e))
exit(0)
示例8: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_BACKSPACE [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
active = self.board.active_ship
if active == 0:
self.change_fract_btn(-1)
elif active == 1:
self.change_fract_btn(1)
self.auto_check_reset()
elif event.type == pygame.KEYDOWN and (event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER):
self.check_result()
elif event.type == pygame.KEYDOWN:
self.auto_check_reset()
lhv = len(self.nm1.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 2:
self.nm1.value = self.nm1.value[0:lhv - 1]
else:
char = event.unicode
if len(char) > 0 and char in self.digits:
self.numbers_disp[0] = int(char)
self.nm1.set_value("0.%s" % char)
self.check_result()
self.nm1.update_me = True
self.mainloop.redraw_needed[0] = True
示例9: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_BACKSPACE [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
active = self.board.active_ship
if self.missing_number == 1:
if active == 0:
self.change_fract_btn(-1, 0)
elif active == 1:
self.change_fract_btn(1, 0)
else:
if active == 0:
self.change_fract_btn(0, -1)
elif active == 1:
self.change_fract_btn(0, 1)
self.auto_check_reset()
elif event.type == pygame.KEYDOWN and (event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER):
self.check_result()
elif event.type == pygame.KEYDOWN:
lhv = len(self.active_num.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.active_num.value = self.active_num.value[0:lhv - 1]
else:
char = event.unicode
if self.typed and len(char) > 0 and lhv < 3 and char in self.digits:
self.active_num.value += char
elif char in self.digits:
self.active_num.value = char
self.typed = True
if len(self.active_num.value) > 0:
self.result[self.missing_number - 1] = int(self.active_num.value)
else:
self.result[self.missing_number - 1] = 0
self.active_num.update_me = True
self.mainloop.redraw_needed[0] = True
self.auto_check_reset()
示例10: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_BACKSPACE [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if not self.show_msg:
if event.type == pygame.KEYDOWN or event.type == pygame.MOUSEBUTTONDOWN:
self.auto_check_reset()
if event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT:
self.home_sqare_switch(self.board.active_ship + 1)
elif event.type == pygame.KEYDOWN and event.key == pygame.K_RIGHT:
self.home_sqare_switch(self.board.active_ship - 1)
elif event.type == pygame.KEYDOWN and event.key == pygame.K_UP:
self.home_sqare_switch(self.board.active_ship - self.sumn1n2sl + 1)
elif event.type == pygame.KEYDOWN and event.key == pygame.K_DOWN:
self.home_sqare_switch(self.board.active_ship + self.sumn1n2sl)
elif event.type == pygame.KEYDOWN and event.key != pygame.K_RETURN and not self.correct:
lhv = len(self.home_square.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.home_square.value = self.home_square.value[0:lhv - 1]
else:
char = event.unicode
if len(char) > 0 and lhv < 2 and char in self.digits:
self.home_square.value = char
if self.auto_select:
self.home_sqare_switch(self.board.active_ship + 1)
else:
self.home_square.value = ""
self.home_square.update_me = True
self.mainloop.redraw_needed[0] = True
elif event.type == pygame.MOUSEBUTTONUP:
self.home_sqare_switch(self.board.active_ship)
示例11: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_BACKSPACE [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if not self.show_msg:
if event.type == pygame.KEYDOWN or event.type == pygame.MOUSEBUTTONDOWN:
self.auto_check_reset()
if event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT:
self.home_sqare_switch(self.board.active_ship + 1)
elif event.type == pygame.KEYDOWN and event.key == pygame.K_RIGHT:
self.home_sqare_switch(self.board.active_ship - 1)
elif event.type == pygame.KEYDOWN and event.key != pygame.K_RETURN and not self.correct:
lhv = len(self.home_square.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.home_square.value = self.home_square.value[0:lhv - 1]
else:
char = event.unicode
if len(char) > 0 and lhv < 2 and char in self.digits:
if lhv == 1:
s = self.home_square.value + char
if s[0] == "0":
self.home_square.value = char
else:
n = int(s)
if n < 20:
self.home_square.value = str(n % 10)
try:
self.carryl[self.home_square.pos_id].value = "1"
self.carryl[self.home_square.pos_id].update_me = True
except:
pass
else:
self.home_square.value = char
else:
self.home_square.value = char
self.home_square.update_me = True
self.mainloop.redraw_needed[0] = True
elif event.type == pygame.MOUSEBUTTONUP:
self.home_sqare_switch(self.board.active_ship)
示例12: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_BACKSPACE [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event)
if not self.show_msg:
if event.type == pygame.KEYDOWN and (event.key != pygame.K_RETURN and event.key != pygame.K_KP_ENTER):
lhv = len(self.home_square.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.home_square.value = self.home_square.value[0:lhv - 1]
elif not self.board.grid[4][18]:
char = event.unicode
if len(char) > 0 and char in self.digits:
self.home_square.value = char
self.home_square.update_me = True
self.mainloop.redraw_needed[0] = True
elif event.type == pygame.MOUSEMOTION and self.drag:
if self.board.grid[4][18]:
self.home_square.value = ""
self.home_square.update_me = True
elif event.type == pygame.MOUSEBUTTONUP:
for each in self.board.units:
if each.is_door is True:
self.board.all_sprites_list.move_to_front(each)
if self.board.grid[4][18]:
self.check_result()
self.home_square.value = ""
self.home_square.update_me = True
elif event.type == pygame.KEYDOWN and (event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER):
self.check_result()
if event.type == pygame.MOUSEBUTTONDOWN:
self.auto_check_reset()
if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP:
self.default_hover(event)
示例13: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_BACKSPACE [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event)
if not self.show_msg:
if event.type == pygame.KEYDOWN and (event.key != pygame.K_RETURN and event.key != pygame.K_KP_ENTER):
lhv = len(self.home_square.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.home_square.value = self.home_square.value[0:lhv - 1]
elif not self.board.grid[4][16]:
char = event.unicode
if len(char) > 0 and char in self.digits:
self.home_square.value = char
self.home_square.update_me = True
self.mainloop.redraw_needed[0] = True
elif event.type == pygame.MOUSEMOTION and self.drag:
if self.board.grid[4][16]:
self.home_square.value = ""
self.home_square.update_me = True
elif event.type == pygame.MOUSEBUTTONUP:
for each in self.board.units:
if each.is_door is True:
self.board.all_sprites_list.move_to_front(each)
if self.board.grid[4][16]:
self.home_square.value = ""
self.home_square.update_me = True
self.check_result()
elif event.type == pygame.KEYDOWN and (event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER):
self.check_result()
if event.type == pygame.MOUSEBUTTONDOWN:
self.auto_check_reset()
if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP:
self.default_hover(event)
示例14: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_BACKSPACE [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event)
if not self.show_msg:
if event.type == pygame.KEYDOWN and (event.key != pygame.K_RETURN and event.key != pygame.K_KP_ENTER):
lhv = len(self.home_square.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.home_square.value = self.home_square.value[0:lhv - 1]
elif not self.board.grid[4][18]:
char = event.unicode
if len(char) > 0 and lhv < 2 and char in self.digits:
self.home_square.value += char
self.home_square.update_me = True
self.mainloop.redraw_needed[0] = True
elif event.type == pygame.MOUSEMOTION and self.drag:
if self.board.grid[4][18]:
self.home_square.value = ""
self.home_square.update_me = True
elif event.type == pygame.MOUSEBUTTONUP:
for each in self.board.units:
if each.is_door is True:
self.board.all_sprites_list.move_to_front(each)
if self.board.grid[4][18]:
self.check_result()
elif event.type == pygame.KEYDOWN and (event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER):
self.check_result()
if event.type == pygame.MOUSEBUTTONDOWN:
self.auto_check_reset()
if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP:
self.default_hover(event)
示例15: test_widget_key_press
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_BACKSPACE [as 别名]
def test_widget_key_press(widget):
"""
Test keypress widget.
:param widget: Widget object
:type widget: :py:class:`pygame_menu.widgets.core.widget.Widget`
"""
widget.update(PygameUtils.key(pygame.K_BACKSPACE, keydown=True))
widget.update(PygameUtils.key(pygame.K_DELETE, keydown=True))
widget.update(PygameUtils.key(pygame.K_LEFT, keydown=True))
widget.update(PygameUtils.key(pygame.K_RIGHT, keydown=True))
widget.update(PygameUtils.key(pygame.K_END, keydown=True))
widget.update(PygameUtils.key(pygame.K_HOME, keydown=True))