-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_gui.py
49 lines (34 loc) · 1.41 KB
/
test_gui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import pygame
from pygame.locals import *
from lib import event, gui
import random
def print_val(val):
print val
def main():
pygame.init()
screen = pygame.display.set_mode((640,480))
event_handler = event.Handler()
main_app = gui.App(screen, event_handler)
some_cont = gui.Container(main_app, (300,100), (50,50))
some_cont.bg_color = (255,255,255, 150)
butt = gui.Button(some_cont, (5,5), "test")
text_box = gui.MessageBox(main_app, (300,100), (50, 200))
text_box.bg_color = (255,0,0,150)
butt.dispatch.bind('click', lambda: text_box.add_line('test'+str(random.randint(0,45))))
inp = gui.Input(some_cont, 290, (5,25))
popup = gui.PopUp(butt, text="adds text to the message box below", width=100)
popup.bg_color = (255,255,255,100)
drop = gui.DropDown(main_app, (5, 5), "press me!")
drop.setChild(gui.Label(main_app, (0,0), 'woah!'))
test = gui.Menu(main_app, gui.RelativePos(to=text_box), ['abc', '123', 'come on now!'])
test2 = gui.DropDownMenu(main_app, gui.RelativePos(x="right", y="top", to=test), 'clickme!', ['abc', '123', 'come on now!'])
test.dispatch.bind('select', print_val)
while 1:
event_handler.update()
if event_handler.quit:
pygame.quit()
return None
screen.fill((0,0,0))
main_app.render()
pygame.display.flip()
main()