Mercurial > rinkhals
comparison gamelib/mainmenu.py @ 6:c0abad23a055
Add start, quit and toggle fullscreen buttons to menu.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Sun, 30 Aug 2009 13:25:04 +0000 |
parents | 67b79658b047 |
children | 99c4f2226314 |
comparison
equal
deleted
inserted
replaced
5:67b79658b047 | 6:c0abad23a055 |
---|---|
3 from pgu import gui | 3 from pgu import gui |
4 import pygame | 4 import pygame |
5 import constants | 5 import constants |
6 | 6 |
7 class MainMenu(gui.Table): | 7 class MainMenu(gui.Table): |
8 def __init__(self,**params): | 8 def __init__(self, **params): |
9 gui.Table.__init__(self,**params) | 9 gui.Table.__init__(self, **params) |
10 | 10 |
11 def fullscreen_changed(btn): | 11 def fullscreen_toggled(): |
12 pygame.display.toggle_fullscreen() | 12 pygame.display.toggle_fullscreen() |
13 | 13 |
14 fg = (255,255,255) | 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) | |
15 | 28 |
16 self.tr() | 29 self.tr() |
17 self.td(gui.Label(constants.NAME, color=fg), colspan=2) | 30 self.td(gui.Label(constants.NAME, color=constants.FG_COLOR), colspan=2) |
18 | 31 |
19 self.tr() | 32 self.tr() |
20 self.td(gui.Label("Start", color=fg), align=1) | 33 self.td(start_button, align=0) |
21 | |
22 btn = gui.Switch(value=False,name='fullscreen') | |
23 btn.connect(gui.CHANGE, fullscreen_changed, btn) | |
24 | 34 |
25 self.tr() | 35 self.tr() |
26 self.td(gui.Label("Full Screen: ",color=fg),align=1) | 36 self.td(fullscreen_toggle, align=0) |
27 self.td(btn) | |
28 | 37 |
29 self.tr() | 38 self.tr() |
30 self.td(gui.Label("Quit", color=fg), align=1) | 39 self.td(quit_button, align=0) |