From 8b55d28060d575a2802a6b155ef7d72a2d46a0c6 Mon Sep 17 00:00:00 2001 From: Dan Anglin Date: Sun, 18 Feb 2024 02:57:32 +0000 Subject: [PATCH] set combobox values to keys from dictionary --- app.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index 79220b8..65c8f35 100644 --- a/app.py +++ b/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(), ), )