source: gamelib/mainmenu.py @ 6:c0abad23a055

Last change on this file since 6:c0abad23a055 was 6:c0abad23a055, checked in by Simon Cross <hodgestar@…>, 11 years ago

Add start, quit and toggle fullscreen buttons to menu.

File size: 1.1 KB
Line 
1"""Main menu."""
2
3from pgu import gui
4import pygame
5import constants
6
7class MainMenu(gui.Table):
8    def __init__(self, **params):
9        gui.Table.__init__(self, **params)
10
11        def fullscreen_toggled():
12            pygame.display.toggle_fullscreen()
13
14        def quit_pressed():
15            pygame.event.post(pygame.event.Event(pygame.QUIT))
16
17        def start_pressed():
18            pygame.event.post(pygame.event.Event(pygame.USEREVENT, event="<Our Start Event Class>"))
19
20        start_button = gui.Button("Start")
21        start_button.connect(gui.CLICK, start_pressed)
22
23        quit_button = gui.Button("Quit")
24        quit_button.connect(gui.CLICK, quit_pressed)
25
26        fullscreen_toggle = gui.Button("Toggle Fullscreen")
27        fullscreen_toggle.connect(gui.CLICK, fullscreen_toggled)
28
29        self.tr()
30        self.td(gui.Label(constants.NAME, color=constants.FG_COLOR), colspan=2)
31
32        self.tr()
33        self.td(start_button, align=0)
34
35        self.tr()
36        self.td(fullscreen_toggle, align=0)
37
38        self.tr()
39        self.td(quit_button, align=0)
Note: See TracBrowser for help on using the repository browser.