-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
37 lines (29 loc) · 1.27 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
from src.lindenmayer_systems import lindenmayer_system
from src.input_manager import auto_inputs, rerun_prev
from src.tkinter_io import tk_input_with_icon, tk_output
from time import sleep
def _clear(clear: bool = True) -> bool:
"""
Function to allow the user to clear the screen after each draw.
:param clear: Should the window be cleared?
© Simon Felix Conrad 2022
"""
return clear
def main():
icon_path = 'icons/app_icon.ico'
turtle = screen = None
run = True
while run: # The user may rerun indefinitely
turtle, screen, *r = auto_inputs(lindenmayer_system, tk_input_with_icon(icon_path), tk_output, True,
kwargs={'_mainloop': False, '_screen_icon': icon_path, '_screen': screen,
'_turtle': turtle})
sleep(3)
# Ask whether the user wants to rerun
run = auto_inputs(rerun_prev, tk_input_with_icon(icon_path), tk_output, False)
# Ask whether the user wants to clear the screen before rerunning
if run and auto_inputs(_clear, tk_input_with_icon(icon_path), tk_output, False):
turtle.clear()
screen.getcanvas().winfo_toplevel().tkraise()
screen.exitonclick()
if __name__ == '__main__':
main()