-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
53 lines (48 loc) · 1.48 KB
/
main.py
File metadata and controls
53 lines (48 loc) · 1.48 KB
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
import matplotlib
matplotlib.use('TkAgg')
from Menu import *
import tkinter as tk
import Strings as s
from Algorithms import Algorithms
ROOT = tk.Tk()
ROOT.withdraw()
def main():
menu = Menu(state='0', title='Algorithm Visualizer', copyright=s.COPYRIGHT)
algo = Algorithms(menu)
while True:
# Menu State Machine:
if menu == '0':
menu.main_page('$\mathtt{Algorithm\ Visualizer}$')
while menu == '0': plt.pause(0.00001)
menu.wait = True
else:
menu.function_page()
# 1. Sort Color's:
if menu == '1':
algo.sort_colors()
elif menu == '2':
algo.num_islands()
elif menu == '3':
algo.max_profit()
elif menu == '4':
algo.add_two_huge_numbers()
elif menu == '5':
algo.rotate_image()
elif menu == '6':
algo.rotated_sorted_array()
elif menu == '7':
algo.nearest_exit()
elif menu == '8':
algo.rotate_list()
elif menu == '9':
algo.calculate_pi()
elif menu == '10':
algo.game_of_life()
# Exit the program:
elif menu == 'Exit':
plt.pause(.25)
plt.close()
break
plt.pause(0.0001)
if __name__ == "__main__":
main()