Python pygame 模块,K_KP_ENTER 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用pygame.K_KP_ENTER

项目:eduActiv8    作者:imiolek-ireneusz    | 项目源码 | 文件源码
def onKeyDown(self, event):
        if not self.select_item:
            if event.type == pygame.KEYDOWN and event.key == pygame.K_DELETE:
                pass
            elif event.type == pygame.KEYDOWN and event.key != pygame.K_RETURN and event.key != pygame.K_KP_ENTER and event.key != pygame.K_TAB:
                lhv = len(self.value)
                if event.key == pygame.K_BACKSPACE:
                    if lhv > 0:
                        if self.ls.lang.ltr_text:
                            self.value = self.value[0:lhv - 1]
                        else:
                            self.value = self.value[1:lhv]
                else:
                    char = event.unicode
                    if len(char) > 0 and lhv < 21:
                        if self.ls.lang.ltr_text:
                            self.value = self.value + char
                        else:
                            self.value = char + self.value
                self.ls.reload_selects()
                self.ls.set_scrollbar_top(self.ls.scroll_min_top)
            elif event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER or event.key == pygame.K_TAB:
                self.nextFocus()

            self.update_trigger()
项目:tingbot-gui    作者:furbrain    | 项目源码 | 文件源码
def touch_handler(self, event):
        #handle keypresses...
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_BACKSPACE:
                self.panel.text.del_letter()
            elif event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER:
                self.panel.new_line()
            elif event.key == pygame.K_ESCAPE:
                self.close(None)
            elif event.key == pygame.K_LEFT:
                self.panel.text.cursor_left()
            elif event.key == pygame.K_RIGHT:
                self.panel.text.cursor_right()
            elif len(event.unicode) > 0:
                self.panel.text.add_letter(event.unicode)
        super(Keyboard,self).touch_handler(event)
项目:eduActiv8    作者:imiolek-ireneusz    | 项目源码 | 文件源码
def onKeyDown(self, event):
        if event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER:
            self.fsubmit()
            self.update_trigger()
项目:solarwolf    作者:pygame    | 项目源码 | 文件源码
def __pygamebox(title, message):
    try:
        import pygame
        pygame.quit() #clean out anything running
        pygame.display.init()
        pygame.font.init()
        screen = pygame.display.set_mode((460, 140))
        pygame.display.set_caption(title)
        font = pygame.font.Font(None, 18)
        foreg, backg, liteg = (0, 0, 0), (180, 180, 180), (210, 210, 210)
        ok = font.render('Ok', 1, foreg, liteg)
        okbox = ok.get_rect().inflate(200, 10)
        okbox.centerx = screen.get_rect().centerx
        okbox.bottom = screen.get_rect().bottom - 10
        screen.fill(backg)
        screen.fill(liteg, okbox)
        screen.blit(ok, okbox.inflate(-200, -10))
        pos = [10, 10]
        for text in message.split('\n'):
            if text:
                msg = font.render(text, 1, foreg, backg)
                screen.blit(msg, pos)
            pos[1] += font.get_height()
        pygame.display.flip()
        stopkeys = pygame.K_ESCAPE, pygame.K_SPACE, pygame.K_RETURN, pygame.K_KP_ENTER
        while 1:
            e = pygame.event.wait()
            if e.type == pygame.QUIT or \
                       (e.type == pygame.KEYDOWN and e.key in stopkeys) or \
                       (e.type == pygame.MOUSEBUTTONDOWN and okbox.collidepoint(e.pos)):
                break
        pygame.quit()
    except pygame.error:
        raise ImportError
项目:PyMonopoly    作者:Kycko    | 项目源码 | 文件源码
def events(self, cur_key):
        for e in pygame.event.get():
            if e.type == pygame.MOUSEBUTTONDOWN and e.button == 1 and cur_key:
                self.action_call(cur_key)
            elif e.type == pygame.KEYDOWN:
                if e.key in (pygame.K_UP, pygame.K_DOWN) and self.cursor:
                    self.cursor.keypress(e.key)
                elif e.key in (pygame.K_RETURN, pygame.K_KP_ENTER) and self.cursor:
                    self.action_call(self.cursor.active_key)
                elif e.key == pygame.K_ESCAPE:
                    actionKEY = ('exit', 'return')['return' in self.menuitems.keys()]
                    self.action_call(actionKEY)
                elif e.key in (pygame.K_LEFT, pygame.K_RIGHT) and self.menuitems and self.cursor and 'SELECTOR' in self.menuitems[self.cursor.active_key].type:
                    self.menuitems[self.cursor.active_key].selector.keypress(e.key)
                elif self.menuitems and ('main_new_edit_player' in self.menuitems['exit'].type or self.menuitems['exit'].type == 'main_settings_player'):
                    self.input_handling(e, 'name_MI', 15)
                elif self.labels and 'property_management_input' in self.labels.keys():
                    self.input_handling(e, 'property_management_input', 2)
                elif self.labels and check_substring_in_dict_keys(self.labels, 'trading_input'):
                    label_key = check_substring_in_dict_keys(self.labels, 'trading_input')
                    if label_key == 'trading_input_fields':
                        max_length = 2
                    elif label_key == 'trading_input_auction_bet':
                        max_length = len(str(Globals.TEMP_VARS['auction']['order'][0].money))
                    else:
                        trader = ('trader', 'tradingwith')['ask_for' in label_key]
                        max_length = len(str(Globals.TEMP_VARS['trading'][trader]['info'].money))
                    self.input_handling(e, label_key, max_length)
                elif self.cursor and e.key in self.menuitems[self.cursor.active_key].HOTKEYS:
                    self.action_call(self.cursor.active_key)
                else:
                    for key in self.menuitems.keys():
                        if self.menuitems[key].type[:4] != 'main' and e.key in self.menuitems[key].HOTKEYS:
                            self.action_call(key)
            elif e.type == pygame.QUIT:
                SYSEXIT()
项目:eduActiv8    作者:imiolek-ireneusz    | 项目源码 | 文件源码
def handle(self, event):
        gd.BoardGame.handle(self, event)  # send event handling up
        if self.show_msg == False:
            if event.type == pygame.KEYDOWN or event.type == pygame.MOUSEBUTTONDOWN:
                self.auto_check_reset()
            if 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 < 3 and char in self.digits):
                        if lhv == 0:
                            self.home_square.value += char
                        elif lhv == 1:
                            if self.home_square == self.ans_h:
                                if self.show_24h:
                                    n = int(self.home_square.value + char)
                                    if n > 23:
                                        self.home_square.value = char
                                    else:
                                        self.home_square.value += char
                                else:
                                    n = int(self.home_square.value + char)
                                    if n > 12:
                                        self.home_square.value = char
                                    else:
                                        self.home_square.value += char
                            if self.home_square == self.ans_m:
                                n = int(self.home_square.value + char)
                                if n > 59:
                                    self.home_square.value = char
                                else:
                                    self.home_square.value += char
                        elif lhv == 2:
                            self.home_square.value = char
                    if len(self.ans_h.value.strip()) > 0:
                        if self.home_square == self.ans_h and self.time[0] == int(self.ans_h.value):
                            self.next_field()
                self.home_square.update_me = True
                self.mainloop.redraw_needed[0] = True
            elif event.type == pygame.KEYDOWN and (
                    event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER) and self.board.active_ship == self.ans_h.unit_id:
                if len(self.ans_h.value.strip()) > 0 and self.time[0] == int(self.ans_h.value):
                    self.next_field()
            elif event.type == pygame.MOUSEBUTTONUP:
                self.home_square.update_me = True
                if self.board.active_ship == self.ans_h.unit_id:
                    self.home_square.perm_outline_width = 5
                    self.home_square = self.ans_h
                    self.board.active_ship = self.ans_h.unit_id
                elif self.board.active_ship == self.ans_m.unit_id:
                    self.home_square.perm_outline_width = 5
                    self.home_square = self.ans_m
                    self.board.active_ship = self.ans_m.unit_id
                self.home_square.update_me = True
                self.mainloop.redraw_needed[0] = True