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


Python locals.KEYDOWN属性代码示例

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


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

示例1: handle_events

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import KEYDOWN [as 别名]
def handle_events(self):
        """
        Obsługa zdarzeń systemowych, tutaj zinterpretujemy np. ruchy myszką

        :return True jeżeli pygame przekazał zdarzenie wyjścia z gry
        """
        for event in pygame.event.get():
            if event.type == pygame.locals.QUIT:
                pygame.quit()
                return True

            from pygame.locals import MOUSEMOTION, MOUSEBUTTONDOWN
            if event.type == MOUSEMOTION or event.type == MOUSEBUTTONDOWN:
                self.population.handle_mouse()

            from pygame.locals import KEYDOWN, K_RETURN
            if event.type == KEYDOWN and event.key == K_RETURN:
                self.started = True


# magiczne liczby używane do określenia czy komórka jest żywa 
开发者ID:koduj-z-klasa,项目名称:python101,代码行数:23,代码来源:code3.py

示例2: dispatch_key

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import KEYDOWN [as 别名]
def dispatch_key(self, name, event):
        if self.visible:

            if event.type == KEYDOWN:
                menubar = self._menubar
                if menubar and menubar.handle_command_key(event):
                    return
            widget = self.focus_switch
            if widget:
                widget.dispatch_key(name, event)
            else:
                self.call_handler(name, event)
        else:
            self.call_parent_handler(name, event) 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:16,代码来源:widget.py

示例3: input

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import KEYDOWN [as 别名]
def input(events):
    for event in events:  # Hit the ESC key to quit the slideshow.
        if (event.type == QUIT or
            (event.type == KEYDOWN and event.key == K_ESCAPE)):
            pygame.quit()
                
#delete files in folder 
开发者ID:drumminhands,项目名称:drumminhands_photobooth,代码行数:9,代码来源:drumminhands_photobooth.py

示例4: test_issue_208

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import KEYDOWN [as 别名]
def test_issue_208(self):
        """PATCH: pygame.scrap on X11, fix copying into PRIMARY selection

           Copying into theX11 PRIMARY selection (mouse copy/paste) would not
           work due to a confusion between content type and clipboard type.

        """

        from pygame import display, event, freetype
        from pygame.locals import SCRAP_SELECTION, SCRAP_TEXT
        from pygame.locals import KEYDOWN, K_y, QUIT

        success = False
        freetype.init()
        font = freetype.Font(None, 24)
        display.init()
        display.set_caption("Interactive X11 Paste Test")
        screen = display.set_mode((600, 200))
        screen.fill(pygame.Color('white'))
        text = "Scrap put() succeeded."
        msg = ('Some text has been placed into the X11 clipboard.'
               ' Please click the center mouse button in an open'
               ' text window to retrieve it.'
               '\n\nDid you get "{}"? (y/n)').format(text)
        word_wrap(screen, msg, font, 6)
        display.flip()
        event.pump()
        scrap.init()
        scrap.set_mode(SCRAP_SELECTION)
        scrap.put(SCRAP_TEXT, text.encode('UTF-8'))
        while True:
            e = event.wait()
            if e.type == QUIT:
                break
            if e.type == KEYDOWN:
                success = (e.key == K_y)
                break
        pygame.display.quit()
        self.assertTrue(success) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:41,代码来源:scrap_test.py

示例5: process_pygame_events

# 需要导入模块: from pygame import locals [as 别名]
# 或者: from pygame.locals import KEYDOWN [as 别名]
def process_pygame_events(self):
        """
        pygame events are how we learn about a window being closed or
        resized or a key being pressed. This function looks for the events
        we care about and reacts when needed.
        """

        for event in pygame.event.get():
            if event.type == QUIT:
                self.running = False
            elif event.type == VIDEORESIZE:
                self.my_weather_rock.sizing(event.size)
            elif event.type == KEYDOWN:

                # On 'q' or keypad enter key, quit the program.
                if ((event.key == K_KP_ENTER) or (event.key == K_q)):
                    self.running = False

                # On 'd' key, set mode to 'daily weather'.
                elif event.key == K_d:
                    self.current_screen = 'd'
                    self.d_count = 1
                    self.h_count = 0
                    self.non_weather_timeout = 0
                    self.periodic_info_activation = 0

                # on 'h' key, set mode to 'hourly weather'
                elif event.key == K_h:
                    self.current_screen = 'h'
                    self.d_count = 0
                    self.h_count = 1
                    self.non_weather_timeout = 0
                    self.periodic_info_activation = 0

                # On 'i' key, set mode to 'info'.
                elif event.key == K_i:
                    self.current_screen = 'i'
                    self.d_count = 0
                    self.h_count = 0
                    self.non_weather_timeout = 0
                    self.periodic_info_activation = 0

                # On 's' key, save a screen shot.
                elif event.key == K_s:
                    self.my_weather_rock.screen_cap() 
开发者ID:genebean,项目名称:PiWeatherRock,代码行数:47,代码来源:runner.py


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