Python pygame.locals.QUIT Examples
The following are 9
code examples of pygame.locals.QUIT().
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: market.py From gym with MIT License | 6 votes |
def render( self, wallet, decision, ) -> None: """Display current state of board. Returns: None """ self.graphics.update( self.price.price_list[:self.tick], wallet, decision, ) for event in pygame.event.get(): if event.type == QUIT: # self.graphics.quit() pygame.quit()
Example #2
Source File: checkers.py From gym with MIT License | 6 votes |
def render( self, ) -> None: """Display current state of board. Returns: None """ self.graphics.update( self.board.board_list, self.piece_location, self.possible_moves, ) for event in pygame.event.get(): if event.type == QUIT: pygame.quit()
Example #3
Source File: drumminhands_photobooth.py From drumminhands_photobooth with MIT License | 5 votes |
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 #4
Source File: __main__.py From code-jam-5 with MIT License | 5 votes |
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())
Example #5
Source File: scrap_test.py From fxxkpython with GNU General Public License v3.0 | 5 votes |
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)
Example #6
Source File: scrap_test.py From fxxkpython with GNU General Public License v3.0 | 5 votes |
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)
Example #7
Source File: scrap_test.py From fxxkpython with GNU General Public License v3.0 | 5 votes |
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)
Example #8
Source File: scrap_test.py From fxxkpython with GNU General Public License v3.0 | 5 votes |
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)
Example #9
Source File: runner.py From PiWeatherRock with MIT License | 4 votes |
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()