-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
66 lines (49 loc) · 1.57 KB
/
main.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import pygame
from form import Form
pygame.init()
clock = pygame.time.Clock()
running = True
screen_width = 800
screen_height = 600
new_form = Form(100,
100,
400,
400)
new_form.add_combo_box('cb1', 50, 50, 100, 50)
for i in range(20):
new_form.combo_boxes['cb1'].add_entry(str(i))
new_form.add_button('b1', 'refresh',50,150,100,50)
def refresh():
new_form.combo_boxes['cb1'].reset()
for i in range(20):
new_form.combo_boxes['cb1'].add_entry(str(i))
def on_change(**kwargs):
name = kwargs['name']
print(new_form.combo_boxes[name].selected_index, new_form.combo_boxes[name].index_offset)
new_form.combo_boxes['cb1'].connect(on_change, True)
new_form.buttons['b1'].connect(refresh)
new_form.render = True
events = {'TextInput': None,
'KeyDown': None,
'MouseWheel': None}
screen = pygame.display.set_mode((screen_width, screen_height))
while running:
# clear screen
screen.fill((0, 0, 0))
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.TEXTINPUT:
events['TextInput'] = event
if event.type == pygame.KEYDOWN:
events['KeyDown'] = event
if event.type == pygame.MOUSEWHEEL:
events['MouseWheel'] = event
if new_form.render:
new_form.update(screen, events)
# clear events dictionary
events = {'TextInput': None,
'KeyDown': None,
'MouseWheel': None}
pygame.display.flip()
clock.tick(120) / 1000