Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions GUI/controls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from dm40.types import ThemePalette


class UIControls:
def __init__(self, master, style, theme: ThemePalette):
def __init__(self, master, style, theme):
self.master = master
self.style = style
self.theme = theme
Expand All @@ -11,7 +8,7 @@ def __init__(self, master, style, theme: ThemePalette):
self._init_layouts()
self.apply_theme()

def use_theme(self, theme: ThemePalette) -> None:
def use_theme(self, theme) -> None:
self.theme = theme
self.apply_theme()

Expand Down
13 changes: 6 additions & 7 deletions GUI/theme_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import tkinter as tk
from tkinter import ttk

from dm40.types import ThemePalette
from dm40.theme_store import deserialize_theme_store_palettes
from shared.theme_store import deserialize_theme_store_palettes
from GUI.widgets.helpers import theme_title_bar
from GUI.widgets.themed_button import ThemedButton

Expand Down Expand Up @@ -34,7 +33,7 @@ def __init__(
self.style = style
self._on_apply = on_apply

self._themes: list[ThemePalette] = deserialize_theme_store_palettes(_DEFAULT_STORE)
self._themes = deserialize_theme_store_palettes(_DEFAULT_STORE)
self._active_theme_idx = self._read_active_index()

self._dialog = None
Expand Down Expand Up @@ -64,7 +63,7 @@ def list_theme_names(self) -> list[str]:
def get_active_theme_index(self) -> int:
return self._active_theme_idx

def get_active_theme(self) -> ThemePalette:
def get_active_theme(self):
return self._themes[self._active_theme_idx]

def activate_theme_index(self, theme_idx: int):
Expand Down Expand Up @@ -234,7 +233,7 @@ def _apply_selected_theme(self):
self._select_listbox_index(self._active_theme_idx)
self._update_preview_from_selection()

def _activate_by_index(self, idx: int) -> tuple[ThemePalette | None, bool]:
def _activate_by_index(self, idx: int):
if idx < 0 or idx >= len(self._themes):
return None, False
if self._active_theme_idx == idx:
Expand All @@ -246,7 +245,7 @@ def _activate_by_index(self, idx: int) -> tuple[ThemePalette | None, bool]:
self._update_listbox_active(old_idx)
return self._themes[idx], True

def _apply_dialog_chrome(self, theme: ThemePalette):
def _apply_dialog_chrome(self, theme):
dialog = self._dialog
if not dialog or not dialog.winfo_exists():
return
Expand All @@ -261,7 +260,7 @@ def _init_preview_styles(self):
self.style.layout(_PREVIEW_BORDER, self.style.layout("Border.TFrame"))
self.style.configure(_PREVIEW_BORDER, relief="solid")

def _apply_preview_colors(self, theme: ThemePalette):
def _apply_preview_colors(self, theme):
self.style.configure(
_PREVIEW_FRAME,
background=theme.bg,
Expand Down
2 changes: 1 addition & 1 deletion GUI/themed_messagebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def _center(self, parent):
h = target_h if target_h else self.winfo_height()
x = parent_x + (parent_w - w) // 2
y = parent_y + (parent_h - h) // 2
self.geometry(f"{w}x{h}+{x}+{y}")
self.geometry("%dx%d+%d+%d" % (w, h, x, y))

def _finish(self, value):
self._result = value
Expand Down
6 changes: 3 additions & 3 deletions GUI/widgets/find_popup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import tkinter as tk
from tkinter import ttk

from dm40.types import ThemePalette



class FindPopup:
Expand All @@ -15,7 +15,7 @@ def __init__(
self,
parent: tk.Misc,
text: tk.Text,
colors: ThemePalette,
colors,
*,
grid_opts: dict | None = None,
):
Expand Down Expand Up @@ -69,7 +69,7 @@ def __init__(
self.set_tag_colors(self._colors)
self.hide(clear=False)

def set_tag_colors(self, colors: ThemePalette) -> None:
def set_tag_colors(self, colors) -> None:
self._colors = colors
text_fg = colors.text
match_bg = colors.outline
Expand Down
10 changes: 2 additions & 8 deletions GUI/widgets/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ class int32(ctypes._SimpleCData):
_DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = intptr_t(-4)


def _hex_to_rgb(value):
b = bytes.fromhex(value[1:])
return b[0], b[1], b[2]


def _set_window_attribute(hwnd, attribute, value):
if not hwnd:
return False
Expand All @@ -45,9 +40,8 @@ def _set_window_attribute(hwnd, attribute, value):
return True


def _colorref_from_hex(value):
r, g, b = _hex_to_rgb(value)
return (b << 16) | (g << 8) | r
def _colorref_from_hex(value, _bf=bytes.fromhex, _ifb=int.from_bytes):
return _ifb(_bf(value[1:]), 'little')


def theme_title_bar(window: tk.Tk | tk.Toplevel, *, border_color: str | None = None,
Expand Down
4 changes: 2 additions & 2 deletions GUI/widgets/tooltip.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _create_tip(self, text: str, x: int, y: int):
)
self._label.pack(fill=tk.BOTH, expand=True)
try:
self._tip.wm_geometry(f"+{x}+{y}")
self._tip.wm_geometry('+%s+%s' % (x, y))
except tk.TclError:
pass
self._current_text = text
Expand All @@ -97,7 +97,7 @@ def move(self, x: int, y: int):
if self._last_xy == xy:
return
try:
self._tip.wm_geometry(f"+{x}+{y}")
self._tip.wm_geometry('+%s+%s' % (x, y))
except tk.TclError:
pass
self._last_xy = xy
Expand Down
10 changes: 4 additions & 6 deletions GUI/widgets/waveform_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import tkinter as tk
from _collections import deque # type: ignore

from dm40.types import ThemePalette


from .tooltip import Tooltip

Expand All @@ -13,7 +13,7 @@ class WaveformView(tk.Canvas):
GRID_FRACS = (0.25, 0.5, 0.75)
_DRAG_PX = 5

def __init__(self, master: tk.Misc, *, colors: ThemePalette, capacity: int = 600):
def __init__(self, master: tk.Misc, *, colors, capacity: int = 600):
super().__init__(master, highlightthickness=2, bd=0)
self._cap = max(16, int(capacity))
self._buf: deque[float] = deque(maxlen=self._cap)
Expand Down Expand Up @@ -272,7 +272,7 @@ def _dismiss(self, _e=None) -> None:

# Theme

def set_colors(self, colors: ThemePalette) -> None:
def set_colors(self, colors) -> None:
fg, trace, grid = colors.text, colors.accent, colors.outline
self.itemconfigure(self._trace_line, fill=trace)
self.itemconfigure(self._hover_line, fill=grid)
Expand Down Expand Up @@ -369,14 +369,12 @@ def redraw(self) -> None:
else:
self._draw_sel(s, e)

# CSV save / record──

def save_buffer_csv(self, path: str) -> int:
"""Write current buffer to *path* as CSV. Returns row count."""
with open(path, "w", newline="") as f:
f.write("Timestamp,Value\n")
for ts, v in zip(self._ts, self._buf):
f.write(f"{ts},{v}\n")
f.write("%s,%s\n" % (ts, v))
return len(self._buf)

def toggle_recording(self, path: str) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion build_release.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
setlocal EnableExtensions EnableDelayedExpansion

set "DEFAULT_MODE_FLAGS=--deployment"
set "DEFAULT_CONSOLE_MODE=disable"
set "DEFAULT_CONSOLE_MODE=force"
set "DEFAULT_MSVC=latest"
set "DEFAULT_PYTHON=py -3.13"
set "DEFAULT_OUT_DIR=build\ci\nuitka"
Expand Down
Loading