def win_screen(): quit_button = Button(display_dimensions, "Quit", (250, 0), (200, 100), red, text_color=white, text_size=25, action="quit") play_again_button = Button(display_dimensions, "Play Again", (0, 0), (200, 100), blue, text_color=white, text_size=25, action="play_again") start_menu_button = Button(display_dimensions, "Start Menu", (-250, 0), (200, 100), green, text_color=white, text_size=25, action="start_menu") buttons = [quit_button, play_again_button, start_menu_button] win_text = Text(display_dimensions, (0, -200), "You Win!!!", 60, black) while True: for event in pygame.event.get(): if event.type == pygame.QUIT: quit_game() elif event.type == pygame.MOUSEBUTTONDOWN: mouse_pos = pygame.mouse.get_pos() if event.button == 1: for button in buttons: if button.check_if_clicked(mouse_pos): if button.action == "quit": quit_game() elif button.action == "play_again": game_loop() elif button.action == "start_menu": start_menu() else: print("Button action: {} does not exist".format(button.action)) game_display.fill(white) for button in buttons: button.display(game_display, pygame.mouse.get_pos()) win_text.display(game_display) pygame.display.update() clock.tick(FPS)
def __init__(self, calendar): Composite.__init__(self) self.calendar = calendar self.dayCheckBoxListener = DayCheckBoxListener(calendar) self.outer = VerticalPanel() self.setWidget(self.outer) self.setStyleName("DynaTable-DayFilterWidget") self.outer.add(DayCheckBox(self, "Sunday", 0)) self.outer.add(DayCheckBox(self, "Monday", 1)) self.outer.add(DayCheckBox(self, "Tuesday", 2)) self.outer.add(DayCheckBox(self, "Wednesday", 3)) self.outer.add(DayCheckBox(self, "Thursday", 4)) self.outer.add(DayCheckBox(self, "Friday", 5)) self.outer.add(DayCheckBox(self, "Saturday", 6)) self.buttonAll = Button("All", self) self.buttonNone = Button("None", self) hp = HorizontalPanel() hp.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) hp.add(self.buttonAll) hp.add(self.buttonNone) self.outer.add(hp) self.outer.setCellVerticalAlignment(hp, HasAlignment.ALIGN_BOTTOM) self.outer.setCellHorizontalAlignment(hp, HasAlignment.ALIGN_CENTER)
def __init__(self, canvas): self.canvas = canvas self.table = Table(self.canvas, Point(100, 25), col_width=150, font_size=10) self.selected_car = None self.show_route = False self.follow_car = False self.show_route_btn = Button( self.flip_show_route, self.canvas, Point(self.canvas.width / 2, 320), width=200, height=30, label='Show Route', font_size=10, ) self.follow_btn = Button( self.flip_follow_car, self.canvas, Point(self.canvas.width / 2, 360), width=200, height=30, label='Follow Selected Car', font_size=10, ) self.buttons = [self.show_route_btn, self.follow_btn]
def __init__(self, title, message, affirmative_label, decline_label="Cancel", width=500, modal=False): Dialog.__init__(self, title=title, width=width, modal=modal) scrollbox = ScrollArea(Label(markup=message, padding=5, overflow=pango.WrapMode.WORD), scroll_horizontal=False, border=0, margin=2, margin_right=3, height=150) affirmative = Button(affirmative_label, id="affirmative_button") affirmative.connect("on-click", self._on_button_click) decline = Button(decline_label, id="decline_button") decline.connect("on-click", self._on_button_click) self.box.contents = VBox([ scrollbox, HBox([HBox(), decline, affirmative], expand=False, padding=10) ])
def initialize(self): print(f"Initializing the '{self.sceneName}' level...") self.startBtn = Button(310, 250, 160, 50, "START") self.infoBtn = Button(200, 350, 370, 50, "INSTRUCTIONS") self.quitBtn = Button(325, 450, 135, 50, "QUIT") self.backBtn = Button(20, 530, 130, 50, "BACK") # assign button colour self.startBtn.set_button_colour(colour.LIGHTBLUE, None) self.infoBtn.set_button_colour(colour.LIGHTBLUE, None) self.quitBtn.set_button_colour(colour.LIGHTBLUE, None) self.backBtn.set_button_colour(colour.LIGHTBLUE, None) # assign action functions to handle button click events self.startBtn.actionFunc = self.__onStartBtnClicked self.infoBtn.actionFunc = self.__onInfoBtnClicked self.quitBtn.actionFunc = self.__onQuitBtnClicked self.backBtn.actionFunc = self.__onBackBtnClicked self.background = load_image("intro.png") self.instructions = load_image("instructions.png") self.startGame = False self.quitGame = False self.showInstructions = False
def __init__(self, owner): self.owner = owner self.bar = DockPanel() self.gotoFirst = Button("<<", self) self.gotoNext = Button(">", self) self.gotoPrev = Button("<", self) self.status = HTML() self.setWidget(self.bar) self.bar.setStyleName("navbar") self.status.setStyleName("status") buttons = HorizontalPanel() buttons.add(self.gotoFirst) buttons.add(self.gotoPrev) buttons.add(self.gotoNext) self.bar.add(buttons, DockPanel.EAST) self.bar.setCellHorizontalAlignment(buttons, HasAlignment.ALIGN_RIGHT) self.bar.add(self.status, DockPanel.CENTER) self.bar.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) self.bar.setCellHorizontalAlignment(self.status, HasAlignment.ALIGN_RIGHT) self.bar.setCellVerticalAlignment(self.status, HasAlignment.ALIGN_MIDDLE) self.bar.setCellWidth(self.status, "100%") self.gotoPrev.setEnabled(False) self.gotoFirst.setEnabled(False)
def game_loop() -> object: undo_button = Button(display_dimensions, "Undo", (10, 10), (30, 30), dark_pink, centered=False, text_size=11, text_color=(217, 139, 121), action="undo") pause_button = Button(display_dimensions, "Pause", (display_dimensions[0] - 50, 10), (40, 30), dark_pink, centered=False, text_size=10, text_color=(217, 139, 121), action="pause") buttons = [undo_button, pause_button] deck = Deck() deck.load_cards() deck.shuffle_cards() deck.load_piles(display_dimensions) hm = history_manager.HistoryManager(deck) while True: for event in pygame.event.get(): if event.type == pygame.QUIT: quit_game() if event.type == pygame.KEYDOWN: if event.key == pygame.K_r: game_loop() elif event.key == pygame.K_w: pass if event.type == pygame.MOUSEBUTTONDOWN: mouse_pos = pygame.mouse.get_pos() if event.button == 1: piles_to_update, valid_move = deck.handle_click(mouse_pos) deck.update(piles_to_update, display_dimensions[1]) if valid_move: hm.valid_move_made(deck) for button in buttons: if button.check_if_clicked(mouse_pos): if button.action == "undo": deck = hm.undo(deck) if event.button == 3: deck.handle_right_click(mouse_pos) game_display.fill(pink) for button in buttons: button.display(game_display, pygame.mouse.get_pos()) deck.display(game_display) pygame.display.update() clock.tick(FPS)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._active_elements = [ Text('Fretboard Unlocker', Text.CENTRE, 20, font=FONTS['heading']), Button('play_namenotes', 'Play Name The Note', Button.CENTRE, 150, width=300), Button('play_findnotes', 'Play Find all Notes', Button.CENTRE, 220, width=300), Button('play_scaledegrees', 'Play name the scale degrees', Button.CENTRE, 290, width=300) ]
def __init__(self): super(SplashScreen, self).__init__() self.font = pygame.font.Font(MAIN_TITLE_FONT[0], 54) self.title = self.font.render(GAME_TITLE, True, (229, 22, 22)) self.title_rect = self.title.get_rect(x=(SCREEN_SIZE[0] / 2) - 220, y=80) self.persist["screen_color"] = "black" self.next_state = "GAMEPLAY" self.menu = Menu([ Button("Start", ((SCREEN_SIZE[0] / 2) - 125, 300, 250, 40)), Button("Credits", ((SCREEN_SIZE[0] / 2) - 125, 350, 250, 40)) ]) self.sound = Sound("assets/sound/MainTheme.wav") self.sound.play()
def __init__(self, file_path, parent_window, on_close): super().__init__(parent_window, on_close, caption='tabulr | Confirm background image', width=640, height=640) # Layer groups bg = OrderedGroup(0) fg = OrderedGroup(1) # Compute image sprite size, preserving aspect ratio bg_image = load(file_path) bg_image.anchor_x = bg_image.width // 2 bg_image.anchor_y = bg_image.height // 2 if bg_image.height > bg_image.width: scale = 640 / bg_image.height else: scale = 640 / bg_image.width # Background gradient gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) self.bg_gradient = self.batch.add( 4, gl.GL_QUADS, fg, ('v2i', (0, 0, 640, 0, 640, 80, 0, 80)), ('c4B', (0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0))) # Draw bg image self.bg_sprite = Sprite(bg_image, batch=self.batch, group=bg, x=320, y=320) self.bg_sprite.scale = scale # Confirmation text self.confirm_text = Text('Is this the image you want to use?', group=fg, size=12, x=self.margin, y=self.margin, bold=True, batch=self.batch) # Confirmation buttons self.buttons = [ Button('yes', self, self.batch, x=590, y=30, group=fg), Button('no', self, self.batch, x=550, y=30, group=fg) ]
def __init__(self): DialogBox.__init__(self) # Use this opportunity to set the dialog's caption. self.setText("About the Mail Sample") # Create a DockPanel to contain the 'about' label and the 'OK' button. outer = DockPanel() outer.setSpacing(4) outer.add(Image(AboutDialog.LOGO_IMAGE), DockPanel.WEST) # Create the 'OK' button, along with a listener that hides the dialog # when the button is clicked. Adding it to the 'south' position within # the dock causes it to be placed at the bottom. buttonPanel = HorizontalPanel() buttonPanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) buttonPanel.add(Button("Close", self)) outer.add(buttonPanel, DockPanel.SOUTH) # Create the 'about' label. Placing it in the 'rest' position within the # dock causes it to take up any remaining space after the 'OK' button # has been laid out. textplain = "This sample application demonstrates the construction " textplain += "of a complex user interface using pyjamas' built-in widgets. Have a look " textplain += "at the code to see how easy it is to build your own apps!" text = HTML(textplain) text.setStyleName("mail-AboutText") outer.add(text, DockPanel.CENTER) # Add a bit of spacing and margin to the dock to keep the components from # being placed too closely together. outer.setSpacing(8) self.add(outer)
def __init__(self, window, bus): super().__init__(window, bus) self.title = Text('Welcome to', batch=self.batch, x=self.margin, y=(self.window.height // 2) + 100) self.title_bold = Text('tabulr', bold=True, batch=self.batch, x=self.margin, y=(self.window.height // 2) + 60) self.subtitle = Text( 'Your schedule, from list to wallpaper. Like magic.', size=12, batch=self.batch, x=self.margin, y=self.window.height // 2) self.init_sprite( 'next_button', Button('next', self.window, self.batch, x=self.margin, y=(self.window.height // 2) - 100)) waves = Sprite(image('front-waves.png'), x=0, y=-30, batch=self.batch) waves.opacity = 140 self.elapsed = 0 self.init_sprite('waves', waves, is_button=False)
def __init__(self): self.fDialogButton = Button("Show Dialog", self) self.fPopupButton = Button("Show Popup", self) panel = VerticalPanel() panel.add(self.fPopupButton) panel.add(self.fDialogButton) list = ListBox() list.setVisibleItemCount(5) for i in range(10): list.addItem("list item " + i) panel.add(list) panel.setSpacing(8) self.setWidget(panel)
def buttonConstructor(): UIfont = pygame.font.SysFont("arial", 30) return [ Button("Wall", UIfont, 50, 620, wallfunc), Button("Start", UIfont, 120, 620, startfunc), Button("End", UIfont, 200, 620, endfunc), Button("Forest", UIfont, 270, 620, forestfunc), Button("CLEAR", UIfont, 410, 620, clearbutton), Button("Breadth", UIfont, 550, 620, breadthbutton), Button("DJ", UIfont, 675, 620, djbutton), Button("Greedy", UIfont, 725, 620, greedybutton), Button("A*", UIfont, 850, 620, astarbutton), ]
def quit(self): self.state = self.FINISHED self._timer.stop() self._active_elements = [ Button('main_menu', 'Return to main menu', Button.CENTRE, 400) ]
def draw_promotion_prompt(screen, screen_width, screen_height, bwidth): board_center = position_to_board((3, 4), bwidth) screen_center = board_to_screen(board_center, screen_width, screen_height, bwidth) # Prompt window window = Window(250, 100) window.set_position(screen_center) # Yes and No buttons yes_button = Button('yes', 100, 50, GREEN) yes_button.set_position( (screen_center[0] + 10, screen_center[1] + 2 * window.height / 4)) no_button = Button('no', 100, 50, RED) no_button.set_position( (2 * screen_center[0] - 140, screen_center[1] + 2 * window.height / 4)) window.add_buttons([yes_button, no_button]) # Draw window and buttons window.draw(screen) # Draw prompt at the center font = pygame.font.SysFont(None, 25) text_surf = font.render("Do you wish to promote?", True, BLACK) text_rect = text_surf.get_rect() board_center = position_to_board((5, 4), bwidth) screen_center = board_to_screen(board_center, screen_width, screen_height, bwidth) text_rect.center = (screen_center[0] + 25, screen_center[1] + 25) screen.blit(text_surf, text_rect) yes_surf = font.render("Yes", True, BLACK) yes_rect = yes_surf.get_rect() board_center = position_to_board((4, 5), bwidth) screen_center = board_to_screen(board_center, screen_width, screen_height, bwidth) yes_rect.center = (screen_center[0] + 10, screen_center[1] + 25) screen.blit(yes_surf, yes_rect) no_surf = font.render("No", True, BLACK) no_rect = no_surf.get_rect() board_center = position_to_board((6, 5), bwidth) screen_center = board_to_screen(board_center, screen_width, screen_height, bwidth) no_rect.center = (screen_center[0] + 40, screen_center[1] + 25) screen.blit(no_surf, no_rect) return window """
def __init__(self, size): super().__init__(size) main_layer = WindowLayer(self) start_button = Button('Start Game', main_layer.rect.center) start_button.add_callback(MouseClickEvent.signal, self._start_game) main_layer.add_child(start_button) self.append_layer(main_layer)
def __init__(self): super(Credits, self).__init__() self.font = pygame.font.Font(SUB_TITLE_FONT[0], 34) self.title = self.font.render("CREDITS", True, (255, 255, 255)) self.title_rect = self.title.get_rect(x=(SCREEN_SIZE[0] / 2) - 80, y=50) self.next_state = "SPLASH" self.menu = Menu([ Button("Back", ((SCREEN_SIZE[0] / 2) - 125, 390, 250, 40), active = True) ])
def onModuleLoad(self): self.page = 0 self.min_page = 1 self.max_page = 10 self.add = Button("Next >", self) self.sub = Button("< Prev", self) self.g = Grid() self.g.resize(5, 5) self.g.setHTML(0, 0, "<b>Grid Test</b>") self.g.setBorderWidth(2) self.g.setCellPadding(4) self.g.setCellSpacing(1) self.updatePageDisplay() RootPanel().add(self.sub) RootPanel().add(self.add) RootPanel().add(self.g)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._game_data = {} self.state = self.READY self._timer = GameTimer() self._active_elements = [] self._start_button = Button( 'start_button', 'Start Game!', Button.CENTRE, 400) self._pause_button = Button( 'pause_button', 'Pause', Button.CENTRE, 400) self._resume_button = Button( 'resume_button', 'Resume!', Button.CENTRE, 400) self._active_elements = [ self._start_button ]
def init(self) -> bool: if SDL_Init(SDL_INIT_VIDEO) < 0: return False self._window = SDL_CreateWindow(GAME_TITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN) if not self._window: return False self._renderer = SDL_CreateRenderer(self._window, -1, SDL_RENDERER_SOFTWARE) if not self._renderer: return False # Game objects board = Board(BOARD_POSITION[0], BOARD_POSITION[1], BOARD_SIZE, CELL_SIZE, WHITE_COLOR) self._game_objects.append(board) # Create piece shapes self._pieces = PieceFactory(board) for piece in self._pieces.create(PIECES_COUNT): self._game_objects.append(piece) # Create menu buttons restart_menu = Button(b"assets/img/restart.bmp", 0, 0, 200, 50, self._renderer, "restart_menu") exit_menu = Button(b"assets/img/exit.bmp", SCREEN_WIDTH - 200, 0, 200, 50, self._renderer, "exit_menu") win_box = Button(b"assets/img/win.bmp", SCREEN_WIDTH // 2 - 200, SCREEN_HEIGHT // 2 - 100, 400, 200, self._renderer, "win_box", False) restart_menu.on_click = lambda: exit_menu.send("slot_restart_game") exit_menu.on_click = lambda: exit_menu.send("slot_exit_game") win_box.on_click = lambda: None win_box.slot_win_game = lambda: win_box.set_show(True) win_box.slot_restart_game = lambda: win_box.set_show(False) self._game_objects.append(restart_menu) self._game_objects.append(exit_menu) self._game_objects.append(win_box) self._running = True return True
def __init__(self): disabledButton = Button("Disabled Button") disabledCheck = CheckBox("Disabled Check") normalButton = Button("Normal Button") normalCheck = CheckBox("Normal Check") panel = VerticalPanel() radio0 = RadioButton("group0", "Choice 0") radio1 = RadioButton("group0", "Choice 1") radio2 = RadioButton("group0", "Choice 2 (Disabled)") radio3 = RadioButton("group0", "Choice 3") hp = HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(normalButton) hp.add(disabledButton) hp = HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(normalCheck) hp.add(disabledCheck) hp = HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(radio0) hp.add(radio1) hp.add(radio2) hp.add(radio3) disabledButton.setEnabled(False) disabledCheck.setEnabled(False) radio2.setEnabled(False) panel.setSpacing(8) self.setWidget(panel)
def start_menu(): title = Text(display_dimensions, (0, -100), "Solitaire", 50, black) play_button = Button(display_dimensions, "Play", (0, 0), (100, 50), blue, text_color=white, text_size=26, action="start_game") quit_button = Button(display_dimensions, "Quit", (200, 0), (100, 50), red, text_color=white, action="quit") options_button = Button(display_dimensions, "Options", (-200, 0), (100, 50), grey, text_color=white, action="options") buttons = [play_button, quit_button, options_button] while True: for event in pygame.event.get(): if event.type == pygame.QUIT: quit_game() if event.type == pygame.MOUSEBUTTONDOWN: mouse_pos = pygame.mouse.get_pos() if event.button == 1: for button in buttons: if button.check_if_clicked(mouse_pos): if button.action == "start_game": game_loop() elif button.action == "quit": quit_game() elif button.action == "options": options_menu() pass else: print("Button action: {} does not exist".format(button.action)) game_display.fill(white) title.display(game_display) for button in buttons: button.display(game_display, pygame.mouse.get_pos()) pygame.display.update() clock.tick(FPS)
def initialize(self): print(f"Initializing the '{self.sceneName}' level...") self.gameOverTxt = Text(400, 100, "courier new", 100, "GAME OVER!", colour.LORANGE, Justify.CENTER) self.scoreTxt = Text(400, 200, "courier new", 50, f"SCORE: {self.score}", colour.RED, Justify.CENTER) self.againBtn = Button(225, 370, 350, 50, "PLAY AGAIN?") self.quitBtn = Button(330, 450, 140, 50, "QUIT") # assign button colour self.againBtn.set_button_colour(colour.LIGHTBLUE, None) self.quitBtn.set_button_colour(colour.LIGHTBLUE, None) # assign action functions to handle button click events self.againBtn.actionFunc = self.__onAgainBtnClicked__ self.quitBtn.actionFunc = self.__onQuitBtnClicked__ self.background = load_image("background1.gif") self.playAgain = False self.quitGame = False
def onModuleLoad(self): b = Button("Click me", greet) RootPanel().add(b) if (1 or 0) and 0: RootPanel().add(Label("or FAILED")) else: RootPanel().add(Label("or OK")) if 0 & 1 == 0: RootPanel().add(Label("& OK")) else: RootPanel().add(Label("& FAILED")) if 1 | 1 != 1: RootPanel().add(Label("| FAILED")) else: RootPanel().add(Label("| OK"))
def createTextThing(self, textBox): p = HorizontalPanel() p.setSpacing(4) p.add(textBox) echo = HTML() select_all = Button("select all") p.add(select_all) p.add(echo) listener=TextBoxListener(self, textBox, echo, select_all) select_all.addClickListener(listener) textBox.addKeyboardListener(listener) textBox.addClickListener(listener) return p
def __init__(self, window, bus, manager): super().__init__(window, bus, draw_waves=True, title='tabulr | Select a background image') self.manager = manager self.title = Text('Select a', batch=self.batch, size=22, x=self.margin, y=self.window.height - self.margin - 22) self.title_bold = Text('background image', bold=True, batch=self.batch, size=22, x=self.margin + self.title.content_width + 8, y=self.window.height - self.margin - 22) # Instructions self.subtitle = Text( 'Enter the path to a valid JPG or PNG image below.', x=self.margin, y=self.window.height * 2 // 3, size=12, batch=self.batch) # Text input input_width = 400 self.path_input = TextInput('', self.margin, self.subtitle.y - 60, input_width, self.batch) self.set_focus(self.path_input) # Error text self.error_msg.y = self.path_input.layout.y - 50 # Image pick button pick_button = Button('pick-image', self.window, self.batch, x=self.margin, y=self.margin) self.init_sprite('pick_button', pick_button) # ImageViewer self.image_viewer = None
def generate_rows(self): self.course_rows = [] self.delete_buttons = [] def truncate_text(text, max_len=10): if len(text) <= max_len: return text return text[:max_len] + '...' base_y = self.labels[5].y - self.labels[5].content_height - 12 course_data = self.pages[self.page] for course_section, course_details in course_data.items(): # Course details course_name, course_venue, course_instructor = course_details course_row = [ Text(truncate_text(course_section, 18), x=self.x_coords[0], y=base_y, size=12, batch=self.batch), Text(truncate_text(course_name), x=self.x_coords[1], y=base_y, size=12, batch=self.batch), Text(truncate_text(course_venue), x=self.x_coords[2], y=base_y, size=12, batch=self.batch), Text(truncate_text(course_instructor, 15), x=self.x_coords[3], y=base_y, size=12, batch=self.batch), ] self.course_rows.append(course_row) # Delete course button self.delete_buttons.append( Button('delete', self, self.batch, x=self.margin, y=base_y - 6)) # Render next row at lower y base_y -= course_row[0].content_height + 16
def __init__(self, window, bus): super().__init__(window, bus, draw_waves=False, title='tabulr | Done') # Check mark check_img = image('check.png') check_img.anchor_x = check_img.width // 2 check_img.anchor_y = check_img.height // 2 check_sprite = Sprite(check_img, x=self.window.width // 2, y=self.window.height // 2 + 120, batch=self.batch) check_sprite.scale = 0.5 self.init_sprite('check', check_sprite, is_button=False) # Text self.title = Text('Done', batch=self.batch, size=22, bold=True, x=self.window.width // 2, y=self.window.height // 3 + 72) self.subtitle = Text('Open the following file to save your wallpaper:', batch=self.batch, size=14, x=self.window.width // 2, y=self.window.height // 3 + 8) self.path = Text(abspath('htmlfile.html'), batch=self.batch, size=8, bold=True, x=self.window.width // 2, y=self.window.height // 3 - 16) self.title.anchor_x = 'center' self.subtitle.anchor_x = 'center' self.path.anchor_x = 'center' # Restart button restart_button = Button('restart', self.window, self.batch, x=self.window.width // 2, y=self.margin) restart_button.x -= restart_button.width // 2 self.init_sprite('restart_button', restart_button)
def options_menu(): settings = settings_manager.load_settings() title_text = Text(display_dimensions, (0, -370), "Options", 40, black) about_text = Text(display_dimensions, (0, 350), "", 14, black) back_button = Button(display_dimensions, "Back", (10, 25), (75, 25), red, centered=False, text_color=white, text_size=14, action="back") buttons = [back_button] draw_three_checkbox = Checkbox(display_dimensions, (10, 100), centered=False, checked=settings['draw_three']) draw_three_label = Text(display_dimensions, (40, 100), "Draw three cards from deck", 14, black, centered=False) while True: for event in pygame.event.get(): if event.type == pygame.QUIT: quit_game() if event.type == pygame.MOUSEBUTTONDOWN: mouse_pos = pygame.mouse.get_pos() if event.button == 1: for button in buttons: if button.check_if_clicked(mouse_pos): if button.action == "back": settings_manager.save_settings({'draw_three': draw_three_checkbox.checked}) start_menu() else: print("Button action: {} does not exist".format(button.action)) draw_three_checkbox.check_if_clicked(mouse_pos) game_display.fill(white) title_text.display(game_display) about_text.display(game_display) draw_three_label.display(game_display) draw_three_checkbox.display(game_display) for button in buttons: button.display(game_display, pygame.mouse.get_pos()) pygame.display.update() clock.tick(FPS)