-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
98 lines (79 loc) · 3.26 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#this is the main program. it controls all the interactions, and sends it to the current page.
#~~~~~~~~~imports~~~~~~~~~#
#modules
import pygame, os
pygame.init()
os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (0, 26) # set the position of the window on the monitor
scrninfo = pygame.display.Info() # this grabs info on the monitor
winwid = scrninfo.current_w
winhig = scrninfo.current_h - 66 # monitor info
dir = os.path.dirname(os.path.realpath(__file__))
hivepng = pygame.image.load(dir + '\images\comb.png') # import the images for the program
pygame.display.set_icon(hivepng)
win = pygame.display.set_mode((winwid, winhig))
pygame.display.set_caption('Hive')
# win = pygame.display.set_mode((winwid, winhig), pygame.FULLSCREEN) #this can be used for fullscreen later
def setup(file):
file.win = win
file.winhig = winhig
file.winwid = winwid
#####SETUP#####
#~~~~~~~~pages~~~~~~~~#It needs to be imported after the stuff above because the display needs to be set, along with fonts and init()
from pages.menupage import menupage
from pages.menupageparent import menupageparent
from pages.schedulepage import schedulepage
from pages.notepadpage import notepadpage
page = menupage()
setup(page)
page.startup()
clock = pygame.time.Clock()
running = True
clicked = False
pageclicked = None
mpos = (0, 0)
while running:
keylist = []
for event in pygame.event.get():
if pygame.mouse.get_pressed()[0]:
mpos = pygame.mouse.get_pos()
if event.type == pygame.MOUSEBUTTONDOWN:
mpos = pygame.mouse.get_pos()
clicked = True
elif event.type == pygame.MOUSEMOTION:
mpos = pygame.mouse.get_pos()
elif event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN:
keylist.append(event.key)
if pageclicked != 'menupage':
page.key = keylist
page.draw(mpos) #let the page draw what it needs to draw
pygame.display.update()
if pageclicked != 'menupage':
page.key = None
if page.isclicked == True:
page.isclicked = False
if clicked:
clicked = False
page.isclicked = True
if page.click(mpos) is not None and page.click(mpos) != True:
page.isclicked = False
pageclicked = page.click(mpos)
if pageclicked == 'menupage': #depending on what button is clicked, it will have a 'destination string' which will come here. The string will determine the next page
page = menupage()
elif pageclicked == 'schedulemenupage':
page = menupageparent('\scheduler\sdata.txt', 'New Schedule', 'schedulepage')
elif pageclicked == 'notepadmenupage':
page = menupageparent(r'\notepad\sdata.txt', 'New File', 'notepadpage')
elif pageclicked == 'todomenupage':
page = menupageparent(r'\todolist\sdata.txt', 'New List', 'todopage')
elif pageclicked == 'notepadpage':
page = notepadpage()
elif pageclicked == 'schedulepage':
page = schedulepage()
elif pageclicked == 'notepadpage':
page = notepadpage()
setup(page)
page.startup()
clock.tick(60) #60 fps I think lol
pygame.quit()