set combobox values to keys from dictionary
This commit is contained in:
parent
9bb23b6c6d
commit
8b55d28060
1 changed files with 6 additions and 4 deletions
10
app.py
10
app.py
|
@ -43,7 +43,7 @@ class App(Tk):
|
|||
|
||||
self.solver = Solver(self.maze)
|
||||
|
||||
self.algorithm_map = {
|
||||
self.search_algorithms = {
|
||||
"Breadth-First Search": self.solver.solve_with_dfs_r,
|
||||
"Depth-First Search": self.solver.solve_with_bfs_r,
|
||||
}
|
||||
|
@ -62,11 +62,13 @@ class App(Tk):
|
|||
command=self.maze.generate,
|
||||
)
|
||||
generate.pack()
|
||||
tuple_of_algorithms = tuple(self.search_algorithms.keys())
|
||||
algorithm = StringVar()
|
||||
combobox = ttk.Combobox(frame, textvariable=algorithm)
|
||||
algorithm.set(tuple_of_algorithms[0])
|
||||
algorithm_label = ttk.Label(frame, text="Searching algorithm:")
|
||||
algorithm_label.pack()
|
||||
combobox["values"] = ("Breadth-First Search", "Depth-First Search")
|
||||
combobox = ttk.Combobox(frame, textvariable=algorithm)
|
||||
combobox["values"] = tuple_of_algorithms
|
||||
combobox["state"] = "readonly"
|
||||
combobox.pack()
|
||||
randomness = BooleanVar()
|
||||
|
@ -82,7 +84,7 @@ class App(Tk):
|
|||
frame,
|
||||
text="Solve the maze",
|
||||
command=lambda: self.solver.solve(
|
||||
solve_method=self.algorithm_map[algorithm.get()],
|
||||
solve_method=self.search_algorithms[algorithm.get()],
|
||||
enable_random_direction=randomness.get(),
|
||||
),
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue