pygui: updates to capture canvas tab change events and set the statusbar zoom variable to be the current canvas

This commit is contained in:
Blake Harnden 2020-12-17 14:56:54 -08:00
parent f9a4fe3331
commit 29ffd64b41
2 changed files with 9 additions and 1 deletions

View file

@ -74,9 +74,17 @@ class CanvasManager:
self.unique_ids: Dict[str, int] = {}
self.draw()
self.setup_bindings()
# start with a single tab by default
self.add_canvas()
def setup_bindings(self) -> None:
self.notebook.bind("<<NotebookTabChanged>>", self.tab_change)
def tab_change(self, _event: tk.Event) -> None:
canvas = self.current()
self.app.statusbar.set_zoom(canvas.ratio)
def draw(self) -> None:
self.notebook = ttk.Notebook(self.master)
self.notebook.grid(sticky=tk.NSEW, pady=1)
@ -145,6 +153,7 @@ class CanvasManager:
for canvas_id in self.notebook.tabs():
self.notebook.forget(canvas_id)
self.canvases.clear()
self.unique_ids.clear()
# reset settings
self.show_node_labels.set(True)

View file

@ -48,7 +48,6 @@ class StatusBar(ttk.Frame):
self.zoom = ttk.Label(self, anchor=tk.CENTER, borderwidth=1, relief=tk.RIDGE)
self.zoom.grid(row=0, column=1, sticky=tk.EW)
# self.set_zoom(self.app.canvas.ratio)
self.cpu_label = ttk.Label(
self, anchor=tk.CENTER, borderwidth=1, relief=tk.RIDGE