-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
47 lines (35 loc) · 1.33 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
#!/usr/bin/env python
import pygame
from pygame.locals import *
import pygame_widgets
from Interface import GUI
class App:
"""Create a single-window app with multiple scenes."""
def __init__(self):
"""Initialize pygame and the application."""
pygame.init()
self.clock = pygame.time.Clock()
self.screenWidth = 1420
self.screenHeight = 800
self.screen = pygame.display.set_mode((self.screenWidth, self.screenHeight), pygame.NOFRAME)
# Initialize interface classes
self.gui = GUI.Gui(self.screen, pygame.event.get())
App.running = True
def run(self):
"""Run the main event loop."""
while App.running: #Could be encapsuled in a try except
# Load GUI
self.gui() # Calls "__call__" inside gui class
for event in pygame.event.get():
if event.type == QUIT:
App.running = False
# Call once every loop to allow widgets to render and listen
pygame_widgets.update(pygame.event.get())
# Update now all changes from above to the screen
pygame.display.update()
self.clock.tick(20)
self.onClose()
def onClose(self):
pygame.quit()
if __name__ == '__main__':
App().run()