def activate(self): ''' toggle the mode associated with the button. ''' from interface import singleton_interface if self.is_active(): singleton_interface.set_mode(NORMAL) else: singleton_interface.set_mode(self.mode)
def process_events(self): """Handle any events that may have accumulated in pygame's event queue""" for event in pygame.event.get(): # process mouse events if event.type == MOUSEBUTTONDOWN: singleton_grid.mouse_click(event.pos) singleton_interface.mouse_press(event.pos) # process key events elif event.type == KEYDOWN: if event.key == K_F4 and (get_mods() & KMOD_ALT): sys.exit(0) elif event.key == K_ESCAPE: singleton_interface.set_mode(interface.NORMAL) elif event.key == K_2 and (get_mods() & KMOD_SHIFT): try: code = get_input("Enter some code to execute.") exec(code) except Exception as e: show_message(str(e)) # process exit signals elif event.type == QUIT: pygame.quit() sys.exit(0)