Skip to content

Commit 48ea872

Browse files
committed
omagahh first release?
1 parent 25d3c8b commit 48ea872

35 files changed

Lines changed: 5614 additions & 0 deletions

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
8+
- package-ecosystem: pip
9+
directory: /.github/workflows
10+
schedule:
11+
interval: weekly
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nuitka==4.0.5

.github/workflows/build.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
tags: ['v*']
6+
workflow_dispatch:
7+
8+
env:
9+
DM40_PYTHON: python
10+
CI: true
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
build:
17+
runs-on: windows-latest
18+
19+
steps:
20+
- uses: actions/checkout@v6
21+
22+
- uses: actions/setup-python@v6
23+
with:
24+
python-version: "3.13"
25+
cache: pip
26+
cache-dependency-path: .github/workflows/CI-requirements.txt
27+
28+
- name: Install Nuitka
29+
run: pip install -r .github/workflows/CI-requirements.txt
30+
31+
- name: Get Nuitka version
32+
id: nuitka-ver
33+
run: |
34+
$ver = python -c "import nuitka.Version; print(nuitka.Version.getNuitkaVersion())"
35+
echo "version=$ver" >> $env:GITHUB_OUTPUT
36+
37+
- name: Cache Nuitka tools
38+
uses: actions/cache@v5
39+
with:
40+
path: ~\AppData\Local\Nuitka\Nuitka\Cache
41+
key: nuitka-tools-${{ runner.os }}-${{ steps.nuitka-ver.outputs.version }}
42+
restore-keys: nuitka-tools-${{ runner.os }}-
43+
44+
- name: Stamp version
45+
id: version
46+
env:
47+
GH_REF: ${{ github.ref }}
48+
GH_REF_NAME: ${{ github.ref_name }}
49+
GH_SHA: ${{ github.sha }}
50+
run: |
51+
if ($env:GH_REF.StartsWith("refs/tags/v")) {
52+
$ver = $env:GH_REF_NAME.TrimStart("v")
53+
} else {
54+
$ver = $env:GH_SHA.Substring(0, 7)
55+
}
56+
echo "ver=$ver" >> $env:GITHUB_OUTPUT
57+
Set-Content -Path dm40/__version__.py -Value "__version__ = `"$ver`"`n"
58+
59+
- name: Build
60+
run: cmd /c build_release.cmd
61+
62+
- name: Rename exe
63+
run: |
64+
$src = "build\ci\nuitka\main.onefile-build\DM40GUI.exe"
65+
$dst = "build\ci\nuitka\main.onefile-build\DM40GUI-${{ steps.version.outputs.ver }}.exe"
66+
Move-Item $src $dst
67+
68+
- name: Upload artifact
69+
uses: actions/upload-artifact@v7
70+
with:
71+
path: build\ci\nuitka\main.onefile-build\DM40GUI-${{ steps.version.outputs.ver }}.exe
72+
archive: false
73+
74+
- name: Release
75+
if: startsWith(github.ref, 'refs/tags/')
76+
uses: softprops/action-gh-release@v2
77+
with:
78+
files: build\ci\nuitka\main.onefile-build\DM40GUI-*.exe

GUI/controls.py

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
from dm40.types import ThemePalette
2+
3+
4+
class UIControls:
5+
def __init__(self, master, style, theme: ThemePalette):
6+
self.master = master
7+
self.style = style
8+
self.theme = theme
9+
style.theme_use("clam")
10+
11+
self._init_layouts()
12+
self.apply_theme()
13+
14+
def use_theme(self, theme: ThemePalette) -> None:
15+
self.theme = theme
16+
self.apply_theme()
17+
18+
def apply_theme(self) -> None:
19+
colors = self.theme
20+
if not self.master.winfo_exists():
21+
return
22+
self.master.tk_setPalette(
23+
background=colors.bg,
24+
foreground=colors.text,
25+
activeBackground=colors.accent,
26+
activeForeground=colors.text,
27+
highlightColor=colors.outline,
28+
highlightBackground=colors.outline,
29+
selectColor=colors.accent,
30+
insertBackground=colors.text,
31+
selectBackground=colors.accent,
32+
selectForeground=colors.text,
33+
)
34+
35+
self._setup_style_colors()
36+
37+
def _init_layouts(self) -> None:
38+
style = self.style
39+
_flat_btn = [("Button.padding", {"sticky": "nswe",
40+
"children": [("Button.label", {"sticky": "nswe"})]})]
41+
42+
style.configure("Border.TFrame", relief="solid")
43+
style.layout("TFrame", [("Frame.padding", {})])
44+
style.layout("Border.TFrame", [("Frame.border", {"sticky": "nswe"})])
45+
style.layout("TLabel", [("Label.label", {"sticky": "nswe"})])
46+
style.layout("DM40.BigValue.TLabel", [("Label.label", {"sticky": "nswe"})])
47+
48+
style.configure("TButton", relief="flat")
49+
style.layout("TButton", _flat_btn)
50+
style.configure("MenuBar.TCheckbutton", relief="flat")
51+
style.layout("MenuBar.TCheckbutton",
52+
[("Checkbutton.padding", {"sticky": "nswe",
53+
"children": [("Checkbutton.label", {"sticky": "nswe"})]})])
54+
style.configure("FindPopup.TButton", padding=(6, 1))
55+
56+
style.configure("Arrowless.Vertical.TScrollbar", gripcount=0)
57+
style.layout("Arrowless.Vertical.TScrollbar", # type: ignore
58+
[("Vertical.Scrollbar.trough",
59+
{"children": [("Vertical.Scrollbar.thumb",
60+
{"expand": 1, "sticky": "ns"})],
61+
"sticky": "ns"})])
62+
63+
def _setup_style_colors(self) -> None:
64+
style = self.style
65+
colors = self.theme
66+
edge = colors.outline
67+
68+
button_base = colors.button
69+
hover_bg = colors.accent_hover
70+
pressed_bg = colors.accent_pressed
71+
72+
def _style_button(name: str, bg: str, hover=hover_bg, pressed=pressed_bg):
73+
style.configure(name, background=bg, foreground=colors.text)
74+
style.map(name,
75+
background=[
76+
("pressed", pressed),
77+
("active", hover),
78+
],
79+
foreground=[("pressed", colors.text), ("active", colors.text)]
80+
)
81+
82+
style.configure("Border.TFrame", background=colors.bg, foreground=colors.text,
83+
bordercolor=edge, lightcolor=edge, darkcolor=edge)
84+
_style_button("TButton", button_base)
85+
_style_button("MenuBar.TButton", colors.bg)
86+
_style_button("FindPopup.TButton", button_base, hover=colors.hover)
87+
88+
style.configure("MenuBar.TCheckbutton", background=colors.bg, foreground=colors.text)
89+
style.map("MenuBar.TCheckbutton",
90+
background=[("selected", pressed_bg), ("active", hover_bg)],
91+
foreground=[("selected", colors.text), ("active", colors.text)]
92+
)
93+
style.configure("TFrame", background=colors.bg)
94+
style.configure("TLabel", background=colors.bg, foreground=colors.text)
95+
style.configure(
96+
"DM40.BigValue.TLabel", foreground=colors.alt_text, background=colors.bg
97+
)
98+
99+
style.configure("TEntry", fieldbackground=colors.widget, foreground=colors.text,
100+
background=colors.widget, bordercolor=edge, lightcolor=edge, darkcolor=edge,
101+
focuscolor=edge, selectbackground=colors.accent, selectforeground=colors.text,
102+
insertcolor=colors.text, inactiveselectbackground=colors.accent)
103+
style.map("TEntry",
104+
fieldbackground=[("readonly", colors.widget)],
105+
bordercolor=[("focus", edge)], lightcolor=[("focus", edge)],
106+
selectbackground=[("!disabled", colors.accent)],
107+
selectforeground=[("!disabled", colors.text)]
108+
)
109+
110+
style.configure("Arrowless.Vertical.TScrollbar", troughcolor=colors.bg,
111+
background=colors.accent_hover, bordercolor=colors.bg,
112+
lightcolor=colors.bg, darkcolor=colors.bg)
113+
style.map("Arrowless.Vertical.TScrollbar", background=[
114+
("disabled", colors.bg), ("pressed", colors.accent_pressed),
115+
("active", colors.accent_hover)])

0 commit comments

Comments
 (0)