Remove ttkbootstrap support
This commit is contained in:
parent
7156bbb6c4
commit
43c26ce9a6
|
|
@ -25,10 +25,6 @@ uv pip install . # install ICRS and dependencies
|
||||||
uv run icrs # launches the GUI
|
uv run icrs # launches the GUI
|
||||||
```
|
```
|
||||||
The launcher copies Tcl/Tk resources into the virtualenv on first run, so no manual environment tweaks are needed.
|
The launcher copies Tcl/Tk resources into the virtualenv on first run, so no manual environment tweaks are needed.
|
||||||
To include the optional ttkbootstrap theme pack:
|
|
||||||
```bash
|
|
||||||
uv pip install '.[ui]'
|
|
||||||
```
|
|
||||||
|
|
||||||
## Workflow
|
## Workflow
|
||||||
1. Load an image (`📂`) or a folder (`📁`).
|
1. Load an image (`📂`) or a folder (`📁`).
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,12 @@
|
||||||
|
|
||||||
from .color_picker import ColorPickerMixin
|
from .color_picker import ColorPickerMixin
|
||||||
from .exclusions import ExclusionMixin
|
from .exclusions import ExclusionMixin
|
||||||
from .theme import ThemeMixin, HAS_TTKBOOTSTRAP
|
from .theme import ThemeMixin
|
||||||
from .ui import UIBuilderMixin
|
from .ui import UIBuilderMixin
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"ColorPickerMixin",
|
"ColorPickerMixin",
|
||||||
"ExclusionMixin",
|
"ExclusionMixin",
|
||||||
"ThemeMixin",
|
"ThemeMixin",
|
||||||
"HAS_TTKBOOTSTRAP",
|
|
||||||
"UIBuilderMixin",
|
"UIBuilderMixin",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,6 @@ from __future__ import annotations
|
||||||
import platform
|
import platform
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
|
|
||||||
try:
|
|
||||||
import ttkbootstrap as tb # type: ignore
|
|
||||||
|
|
||||||
HAS_TTKBOOTSTRAP = True
|
|
||||||
except Exception: # pragma: no cover - optional dependency
|
|
||||||
tb = None
|
|
||||||
HAS_TTKBOOTSTRAP = False
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import winreg
|
import winreg
|
||||||
except Exception: # pragma: no cover - platform-specific
|
except Exception: # pragma: no cover - platform-specific
|
||||||
|
|
@ -24,27 +16,12 @@ class ThemeMixin:
|
||||||
|
|
||||||
theme: str
|
theme: str
|
||||||
style: ttk.Style
|
style: ttk.Style
|
||||||
using_tb: bool
|
|
||||||
scale_style: str
|
scale_style: str
|
||||||
|
|
||||||
def init_theme(self) -> None:
|
def init_theme(self) -> None:
|
||||||
"""Initialise ttk style handling and apply the detected theme."""
|
"""Initialise ttk style handling and apply the detected theme."""
|
||||||
if HAS_TTKBOOTSTRAP:
|
|
||||||
try:
|
|
||||||
try:
|
|
||||||
self.root.tk.call("package", "require", "msgcat") # type: ignore[attr-defined]
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
self.style = tb.Style()
|
|
||||||
self.using_tb = True
|
|
||||||
except Exception:
|
|
||||||
self.style = ttk.Style()
|
self.style = ttk.Style()
|
||||||
self.style.theme_use("clam")
|
self.style.theme_use("clam")
|
||||||
self.using_tb = False
|
|
||||||
else:
|
|
||||||
self.style = ttk.Style()
|
|
||||||
self.style.theme_use("clam")
|
|
||||||
self.using_tb = False
|
|
||||||
|
|
||||||
self.theme = "light"
|
self.theme = "light"
|
||||||
self.apply_theme(self.detect_system_theme())
|
self.apply_theme(self.detect_system_theme())
|
||||||
|
|
@ -54,16 +31,6 @@ class ThemeMixin:
|
||||||
mode = (mode or "light").lower()
|
mode = (mode or "light").lower()
|
||||||
self.theme = "dark" if mode == "dark" else "light"
|
self.theme = "dark" if mode == "dark" else "light"
|
||||||
|
|
||||||
if HAS_TTKBOOTSTRAP:
|
|
||||||
try:
|
|
||||||
theme_name = "darkly" if self.theme == "dark" else "flatly"
|
|
||||||
self.style.theme_use(theme_name)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
self.scale_style = (
|
|
||||||
"info.Horizontal.TScale" if self.theme == "dark" else "primary.Horizontal.TScale"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
self.scale_style = "Horizontal.TScale"
|
self.scale_style = "Horizontal.TScale"
|
||||||
|
|
||||||
if self.theme == "dark":
|
if self.theme == "dark":
|
||||||
|
|
@ -77,7 +44,6 @@ class ThemeMixin:
|
||||||
s = self.style
|
s = self.style
|
||||||
s.configure("TFrame", background=bg)
|
s.configure("TFrame", background=bg)
|
||||||
s.configure("TLabel", background=bg, foreground=fg, font=("Segoe UI", 10))
|
s.configure("TLabel", background=bg, foreground=fg, font=("Segoe UI", 10))
|
||||||
if not HAS_TTKBOOTSTRAP:
|
|
||||||
s.configure(
|
s.configure(
|
||||||
"TButton", padding=8, relief="flat", background="#e0e0e0", foreground=fg, font=("Segoe UI", 10)
|
"TButton", padding=8, relief="flat", background="#e0e0e0", foreground=fg, font=("Segoe UI", 10)
|
||||||
)
|
)
|
||||||
|
|
@ -123,4 +89,4 @@ class ThemeMixin:
|
||||||
self.update_preview() # type: ignore[attr-defined]
|
self.update_preview() # type: ignore[attr-defined]
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["ThemeMixin", "HAS_TTKBOOTSTRAP"]
|
__all__ = ["ThemeMixin"]
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,6 @@ dependencies = [
|
||||||
"pillow>=10.0.0",
|
"pillow>=10.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.optional-dependencies]
|
|
||||||
ui = ["ttkbootstrap>=1.10.0"]
|
|
||||||
|
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
icrs = "app.launcher:main"
|
icrs = "app.launcher:main"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue