I created the new branch that will use PyOSG.
[krufty_fps.git] / pygame_gui / test_suite.py
blob57abb0282b1bef3b87df08d82a6955824213dffd
1 #!/usr/bin/python
3 # this tests my gui
5 from DerGUI import *
7 WINDOW_SIZE = (640, 480)
9 THEME_FILE = 'theme_two.zip'
10 WIDGET_FILE = 'widgets.xml'
12 def main():
14 the_display = pygame_init()
15 make_gui()
17 run(the_display)
19 return
21 def pygame_init():
23 pygame.init()
24 return pygame.display.set_mode(WINDOW_SIZE)
26 def make_gui():
28 global gui_system
29 gui_system = GUISystem(WIDGET_FILE, THEME_FILE)
31 global widgets
32 widgets = {}
34 params_a = {'x': 100, 'y': 50, 'width': 150, 'height': 50, 'text': 'a label'}
35 widgets['test_label'] = gui_system.makeWidget('label', params_a)
37 params_b = {'x': 75, 'y': 150, 'width': 200, 'height': 50, 'text': 'Hide/Show Label'}
38 widgets['button_toggle'] = gui_system.makeWidget('button', params_b)
40 params_c = {'x': 100, 'y': 250, 'width': 200, 'height': 35, 'text': ''}
41 widgets['textbox_test'] = gui_system.makeWidget('textbox', params_c)
43 widgets['button_toggle'].connect('BUTTON_CLICKED', button_clicked)
45 return
47 def button_clicked(params, more_params):
49 global widgets
50 if widgets['test_label'].params['parameters']['visible']:
51 widgets['test_label'].hide()
52 else:
53 widgets['test_label'].show()
55 return
57 def run(the_display):
59 my_image = pygame.image.load('turkey.jpg').convert()
61 global gui_system
63 quit = 0
64 getting_events = 1
66 while not quit:
68 while getting_events:
69 the_event = pygame.event.poll()
70 if the_event.type == pygame.QUIT:
71 quit = 1
72 if the_event.type == pygame.NOEVENT:
73 getting_events = 0
75 gui_system.event(the_event)
77 getting_events = 1
79 the_display.blit(my_image, (0, 0))
80 gui_system.draw(the_display)
81 pygame.display.flip()
83 return
85 if __name__ == '__main__':
86 main()
88 # end