fix: require license gate before gui entry
This commit is contained in:
1 parent
407c3b37c2
commit
f5a77867ee
8 files changed
+268
-9
No files matched your search
@@ -222,21 +222,35 @@ class RoundedNavButton(tk.Canvas):
|
||||
self.text = _with_icon(text, NAV_ICONS.get(text))
|
||||
self.command = command
|
||||
self.active = active
|
||||
self.enabled = True
|
||||
super().__init__(parent, height=46, bg=theme.SURFACE, highlightthickness=0, bd=0, cursor="hand2")
|
||||
self.bind("<Configure>", lambda _e: self._draw())
|
||||
self.bind("<Button-1>", lambda _e: self.command())
|
||||
self.bind("<Button-1>", lambda _e: self._invoke())
|
||||
self.bind("<Enter>", lambda _e: self._draw(hover=True))
|
||||
self.bind("<Leave>", lambda _e: self._draw())
|
||||
|
||||
def _invoke(self) -> None:
|
||||
if self.enabled:
|
||||
self.command()
|
||||
|
||||
def set_active(self, active: bool) -> None:
|
||||
self.active = active
|
||||
self._draw()
|
||||
|
||||
def set_enabled(self, enabled: bool) -> None:
|
||||
self.enabled = bool(enabled)
|
||||
self.configure(cursor="hand2" if self.enabled else "arrow")
|
||||
self._draw()
|
||||
|
||||
def _draw(self, hover: bool = False) -> None:
|
||||
self.delete("all")
|
||||
width = max(1, self.winfo_width())
|
||||
bg = theme.TEAL_SOFT if self.active else (theme.SURFACE_HOVER if hover else theme.SURFACE)
|
||||
fg = theme.TEAL_DARK if self.active else theme.TEXT
|
||||
if not self.enabled:
|
||||
bg = theme.SURFACE
|
||||
fg = theme.MUTED
|
||||
else:
|
||||
bg = theme.TEAL_SOFT if self.active else (theme.SURFACE_HOVER if hover else theme.SURFACE)
|
||||
fg = theme.TEAL_DARK if self.active else theme.TEXT
|
||||
rounded_rect(self, 1, 4, width - 2, 42, theme.RADIUS_SM, fill=bg, outline=bg)
|
||||
if self.active:
|
||||
rounded_rect(self, 4, 12, 10, 34, 4, fill=theme.TEAL, outline=theme.TEAL)
|
||||
|
||||
Reference in new issue
Block a user