Python pygame.locals.K_ESCAPE Examples

The following are 11 code examples of pygame.locals.K_ESCAPE(). 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 pygame.locals , or try the search function .
Example #1
Source File: widget.py    From GDMC with ISC License 6 votes vote down vote up
def key_down(self, event):
        k = event.key
        #print "Widget.key_down:", k ###
        if k == K_RETURN or k == K_KP_ENTER:
            if self.enter_response is not None:
                self.dismiss(self.enter_response)
                return
        elif k == K_ESCAPE:
            self.root.fix_sticky_ctrl()
            if self.cancel_response is not None:
                self.dismiss(self.cancel_response)
                return
        elif k == K_TAB:
            self.tab_to_next()
            return
        self.call_parent_handler('key_down', event) 
Example #2
Source File: widget.py    From MCEdit-Unified with ISC License 6 votes vote down vote up
def key_down(self, event):
        k = event.key
        #print "Widget.key_down:", k ###
        if k == K_RETURN or k == K_KP_ENTER:
            if self.enter_response is not None:
                self.dismiss(self.enter_response)
                return
        elif k == K_ESCAPE:
            self.root.fix_sticky_ctrl()
            if self.cancel_response is not None:
                self.dismiss(self.cancel_response)
                return
        elif k == K_TAB:
            self.tab_to_next()
            return
        self.call_parent_handler('key_down', event) 
Example #3
Source File: no_rendering_mode.py    From scenario_runner with MIT License 5 votes vote down vote up
def _is_quit_shortcut(key):
        return (key == K_ESCAPE) or (key == K_q and pygame.key.get_mods() & KMOD_CTRL)


# ==============================================================================
# -- Global Objects ------------------------------------------------------------
# ============================================================================== 
Example #4
Source File: carla08interface.py    From coiltraine with MIT License 5 votes vote down vote up
def _is_quit_shortcut(key):
        return (key == K_ESCAPE) or (key == K_q and pygame.key.get_mods() & KMOD_CTRL)


# ==============================================================================
# -- HUD -----------------------------------------------------------------
# ============================================================================== 
Example #5
Source File: carla09interface.py    From coiltraine with MIT License 5 votes vote down vote up
def _is_quit_shortcut(key):
        return (key == K_ESCAPE) or (key == K_q and pygame.key.get_mods() & KMOD_CTRL) 
Example #6
Source File: manual_control.py    From macad-gym with MIT License 5 votes vote down vote up
def _is_quit_shortcut(key):
        return (key == K_ESCAPE) or (key == K_q and pygame.key.get_mods() & KMOD_CTRL)


# ==============================================================================
# -- HUD -----------------------------------------------------------------------
# ============================================================================== 
Example #7
Source File: spawn_control.py    From macad-gym with MIT License 5 votes vote down vote up
def _is_quit_shortcut(key):
        return (key == K_ESCAPE) or (key == K_q
                                     and pygame.key.get_mods() & KMOD_CTRL)


# ==============================================================================
# -- HUD -----------------------------------------------------------------------
# ============================================================================== 
Example #8
Source File: keyboard_control.py    From macad-gym with MIT License 5 votes vote down vote up
def _is_quit_shortcut(key):
        return (key == K_ESCAPE) or (key == K_q
                                     and pygame.key.get_mods() & KMOD_CTRL) 
Example #9
Source File: drumminhands_photobooth.py    From drumminhands_photobooth with MIT License 5 votes vote down vote up
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 
Example #10
Source File: carla_manual_control.py    From ros-bridge with MIT License 5 votes vote down vote up
def _is_quit_shortcut(key):
        return (key == K_ESCAPE) or (key == K_q and pygame.key.get_mods() & KMOD_CTRL)


# ==============================================================================
# -- HUD -----------------------------------------------------------------------
# ============================================================================== 
Example #11
Source File: __main__.py    From code-jam-5 with MIT License 5 votes vote down vote up
def update(self):
        """Called on new frame."""
        self.clock.tick(60)
        new_time = time.time()
        self.time_delta = new_time - self.last_update_time
        self.last_update_time = new_time
        self.score += self.energy_per_second * self.time_delta
        for event in pygame.event.get():
            if event.type == QUIT or (event.type == KEYDOWN
                                      and event.key == K_ESCAPE):
                self.exit_requested = True
                return
            if event.type == MOUSEBUTTONDOWN:
                pos = pygame.mouse.get_pos()
                if self.crank.rect.collidepoint(pos):
                    self.crank.clicked()
                for button in self.all_buttons:
                    if button.rect.collidepoint(pos):
                        button.clicked()
                for machine in self.machines.values():
                    if machine.rect.collidepoint(pos):
                        if self.score >= machine.cost:
                            self.score -= machine.cost
                            machine.count += 1
                            self.events.send(f"buy_machine_{machine.name}")

        if self.score >= 5.67e5 and not self.congrats_message:
            self.congrats_message = StaticImage((0.5, 0.8), images["congrats"])
            self.gui_plain.add(self.congrats_message)
            self.events.send("win")

        for sprite_layer in self.sprite_layers:
            sprite_layer.update()
        self.screen.blit(self.background, (0, 0))
        self.screen.fill(self.overlay_color, rect=self.overlay1, special_flags=pygame.BLEND_MULT)
        self.screen.fill(self.overlay_color, rect=self.overlay2, special_flags=pygame.BLEND_MULT)
        for sprite_layer in self.sprite_layers:
            sprite_layer.draw(self.screen)
        pygame.display.flip()
        say(self.events.get_current_message())