-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
56 lines (47 loc) · 1.54 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
import os
from util import booleans, files
from typing import Self
from themes import *
import static
import pygame
on = True
def main():
global on
pygame.init()
pygame.mixer.init()
theme = Theme.load("default")
size = windowWidth, windowHeight = 800, 600
scr = pygame.display.set_mode(size, pygame.RESIZABLE | pygame.SRCALPHA | pygame.HWSURFACE, 32)
pygame.display.set_allow_screensaver(True)
pygame.display.set_caption("Hexsense")
# pygame.display.set_icon(pygame.image.load_basic("./logo.png"))
body = BodyNode()
body.style.background = theme.windowBackground
body.fullRender(scr, 0, 0)
topBar = Element("nav")
topBar.style.height = 30
topBar.style.borderBottomColor = theme.topHr
topBar.style.borderBottomSize = 2
body.append(topBar)
logo = Element("p")
logo.append(TextNode("Hexsense"))
topBar.append(logo)
print(topBar.style.height, topBar.size())
mouseX, mouseY = 0, 0
while on:
for ev in pygame.event.get():
if ev.type == pygame.QUIT:
on = False
break
elif ev.type == pygame.VIDEORESIZE:
windowWidth, windowHeight = ev.w, ev.h
size = ev.size
body._inited = False
elif ev.type == pygame.MOUSEMOTION:
mouseX, mouseY = ev.pos
elif ev.type == pygame.MOUSEBUTTONDOWN:
body.invokeClick(*ev.pos)
body.fullRender(scr, mouseX, mouseY)
pygame.display.update()
if __name__ == "__main__":
main()