-
Notifications
You must be signed in to change notification settings - Fork 1
/
gui_menu.py
38 lines (27 loc) · 1.09 KB
/
gui_menu.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
from tkinter import *
from tkinter import messagebox
from threading import Thread
def start_pressed(board, is_visual):
if len(board.target_points) >= 2:
Thread(target=board.find_path, args=(is_visual.get(), ), daemon=True).start() # start the path finding procedure
else:
pop_up_message("You need to specify a start and end point by using your middle mouse button")
def pop_up_message(message):
messagebox.showerror("Error", message)
def reset_pressed(board):
board.reset()
def gui(board):
global start_button, message_box
root = Tk()
root.geometry("300x100")
root.title("A* Pathfinding Example")
is_visual = IntVar()
is_visual.set(1)
start_button = Button(root,
text="START",
command=lambda: start_pressed(board, is_visual)).pack()
reset_button = Button(root,
text="RESET",
command=lambda: reset_pressed(board)).pack()
visual_checkbox = Checkbutton(root, text="Show Visual Search", variable=is_visual).pack()
root.mainloop()