Make toolbar updating more sensible
@@ -122,7 +122,6 @@ class Workbench(tk.Tk):
self._init_commands()
self._init_icon()
- self._update_toolbar()
try:
self._editor_notebook.load_startup_files()
except Exception:
@@ -363,6 +362,7 @@ class Workbench(tk.Tk):
self.update_idletasks() # allow UI to complete
thonny._runner = self._runner
self._runner.start()
+ self._update_toolbar()
except:
self.report_exception("Error when initializing backend")
@@ -1170,6 +1170,8 @@ class Workbench(tk.Tk):
except:
self.report_exception("Problem when handling '" + sequence + "'")
+ self._update_toolbar()
+
def bind(self, sequence: str, func: Callable, add: bool=None) -> None: # type: ignore
"""Uses custom event handling when sequence doesn't start with <.
Otherwise forwards the call to Tk's bind"""
@@ -1319,6 +1321,9 @@ class Workbench(tk.Tk):
create_tooltip(button, tooltip_text)
def _update_toolbar(self) -> None:
+ if not hasattr(self, "_toolbar"):
+ return
+
for group_frame in self._toolbar.grid_slaves(0):
for button in group_frame.pack_slaves():
if thonny._runner is None or button.tester and not button.tester():
@@ -1326,8 +1331,6 @@ class Workbench(tk.Tk):
else:
button["state"] = tk.NORMAL
- self.after(300, self._update_toolbar)
-
def _cmd_zoom_with_mouse(self, event) -> None:
if event.delta > 0:
