From b85d426bf529ffb1a76d075952386c2efc8373cb Mon Sep 17 00:00:00 2001 From: Daniel Nagel Date: Mon, 5 Jan 2026 21:17:16 +0100 Subject: [PATCH] Hauptseite mit Fenstern und Buttons --- .venv/pyvenv.cfg | 2 +- READ ME | 2 + __pycache__/gui.cpython-312.pyc | Bin 0 -> 134 bytes __pycache__/gui_dashboard.cpython-312.pyc | Bin 0 -> 1713 bytes gui/__pycache__/gui_dashboard.cpython-312.pyc | Bin 0 -> 3702 bytes gui/__pycache__/styles.cpython-312.pyc | Bin 0 -> 421 bytes gui/gui_dashboard.py | 44 ++++++++++++++++++ gui/styles.py | 9 ++++ main.py | 22 +++++++-- workers/ping_worker.py | 6 +++ 10 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 READ ME create mode 100644 __pycache__/gui.cpython-312.pyc create mode 100644 __pycache__/gui_dashboard.cpython-312.pyc create mode 100644 gui/__pycache__/gui_dashboard.cpython-312.pyc create mode 100644 gui/__pycache__/styles.cpython-312.pyc create mode 100644 gui/gui_dashboard.py create mode 100644 gui/styles.py create mode 100644 workers/ping_worker.py diff --git a/.venv/pyvenv.cfg b/.venv/pyvenv.cfg index 8f51041..9e93342 100644 --- a/.venv/pyvenv.cfg +++ b/.venv/pyvenv.cfg @@ -2,4 +2,4 @@ home = /usr/bin include-system-site-packages = false version = 3.12.3 executable = /usr/bin/python3.12 -command = /usr/bin/python3 -m venv /mnt/Daten/repos/HomeDashboard/.venv +command = /mnt/Daten/repos/HomeDashboard/.venv/bin/python3 -m venv /mnt/Daten/repos/HomeDashboard/.venv diff --git a/READ ME b/READ ME new file mode 100644 index 0000000..f431f09 --- /dev/null +++ b/READ ME @@ -0,0 +1,2 @@ +source .venv/bin/activate 17:37:58 +python3 main.py diff --git a/__pycache__/gui.cpython-312.pyc b/__pycache__/gui.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3d93bdeadbc2a68d15b05927467b3dadc15a1688 GIT binary patch literal 134 zcmX@j%ge<81k3cIGC}lX5P=Rpvj9b=GgLBYGWxA#C}INgK7-W!Qq|ARE75mJEJ@AN zFG?-QFV^?S&rNknEY3*EPb^B&PcO~XE2#X%VUwGmQks)$SHud`#R$a3AjU^#Mn=XW HW*`dy_3j-q literal 0 HcmV?d00001 diff --git a/__pycache__/gui_dashboard.cpython-312.pyc b/__pycache__/gui_dashboard.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8b78d31fd4d91c4a46b160cea5808a66f9dfb037 GIT binary patch literal 1713 zcmeHI&1(}u6rb6h{YaXm646quZLn0>LYgX8JyZ``LV9S9#TKM&vTM6#vm5rqHa!^- zBveRlJqhAX>Oawgy?7}YJPZ*JdhynpLm?;MY?8JKm0lH`W#7#2?VH~`-pA~xXf%vq zynDKAyx|b~&Omnn4n}hXrX8dq4V$QdmoY{f_Yy608V`~$5k>gP3>8c{-^d4hIzob( zhqpNkatC?1`*FQX-c`V?;oZ)6eAbejG3hK%E!WuzeM95U<&pc$0Pc2FGw8w-`Exmg z;PvwUfiu!;#gInM<@|5i6RLkPO3*6s>~?A#+NBSd&^Wq(d+mozl1h$ zzrKXpdPT@?#WJezCgxOkEoZBaww3VoO)q(8(@Z?GEiaj~O|7lUnZBO9J3URqS@pTG zs(OZPQSp)QdA6lU4r@pnE~=~gif4GHP6boV=_Zx(rs}%7OGzH+Deu@DRLljt-lHZ< zN-LErSYB#Q^>i!c=tbL2W$c1};!~z59{i|3+V#OZzU4&W1SiJCAP6dgj%D%+fMIxDmeO`6)8%w6 z^p<=f6M=nJAyl%Aybc8s@CDfqHujOW} KlNjF&h<^hKTp0ZT literal 0 HcmV?d00001 diff --git a/gui/__pycache__/gui_dashboard.cpython-312.pyc b/gui/__pycache__/gui_dashboard.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..944181a46fb6ec39e078d02fc390fc977547f6ca GIT binary patch literal 3702 zcmb_eO>7fK6rTODch^pwghGBu35L*sY5qe?f1;F>kOYZ_Lujj{NY>iBi8oo>(d;@V z7K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j%e_67jS*2%&1Qez=?s zyDy^a;gER^mmHKK41c4+>H7{Ig^Js%+m)aKER;%4>^pOotSejj!y>=zZ)y28G z)%wl^*R_Rc=EDuvzBIfryjpoE!8Rq?mN?sTclKT&e*E+r`yQD*zi|G#nqV8VbNJh< zcdmXnkU0MS8vDVv4J5qe5${-vE<~@*CAs=ISN~Ogf;+l}?99hhR{HhJ3HD%;JsM|^ z-hKDpu{*tMZ0CmHyj6Rn_RIRD&=40IRu6V3gq|(L+F%ttErc7wa%sp>Z2sMIzF3kF6>4=q)MvYXdB%Mm!9z1P(K-4Gzl_Sk?j_3KMY}QRFt^5;qbi zLXMLOl3nxYxwB$^0M2mf;=;vs_JC>Mh{tJgA;mAlLpGaz&}!H8IW_wlHuV|KtSZr` z%9)%ZnPWP@U=(=nnhJ{n5ilDPGNQ_T_%tvR>$F}VDTbn`XQ=iWI`o|5=h^2Jv(&WE kv_%V4cbY+Tb&9lJ)VnCx3pYizq*TrZc24q%fv1r7)+kq_C#2&0&jTsASjV zs8T3NttinosmM`C%g-y(P0G(nfe0n#l&0#M85lrS7!g!qh)0D4*p{Tk;#7#?#W{&3 zsk#`h+BbOhKk~A3F*ULkfno;$w-td; literal 0 HcmV?d00001 diff --git a/gui/gui_dashboard.py b/gui/gui_dashboard.py new file mode 100644 index 0000000..320ccb1 --- /dev/null +++ b/gui/gui_dashboard.py @@ -0,0 +1,44 @@ +from nicegui import ui +from gui.styles import STYLES + +site = 1 + +@ui.refreshable +def content (): + match site: + case (1): + ui.label("Startseite. Willkommen!").classes(STYLES["h2"]) + case (2): + ui.label("Energie und Verbrauch").classes(STYLES["h2"]) + case (3): + ui.label("Heizung").classes(STYLES["h2"]) + case (4): + ui.label("Homelab").classes(STYLES["h2"]) + + +def create_ui(): + ui.page_title("Haus Dashboard") + with ui.row().classes("w-full justify-between"): + ui.label("Haus Dashboard").classes(STYLES["header"]) + ui.switch('Light Mode').bind_value(ui.dark_mode(True)) + + with ui.card().classes("w-full"): + ui.label("Navigation").classes(STYLES["h1"]) + with ui.row().classes('w-full justify-between'): + ui.button('Startseite', on_click=lambda: ui_site_changer(1)) + ui.button('Energie', on_click=lambda: ui_site_changer(2)) + ui.button('Heizung', on_click=lambda: ui_site_changer(3)) + ui.button('Homelab', on_click=lambda: ui_site_changer(4)) + with ui.card().classes("w-full"): + content() + +def run_ui(): + ui.run(host='0.0.0.0', port=8080) + +#Wechsel den int von site je nach Button der gedrückt wurde. +def ui_site_changer(i: int): + global site + site = i + content.refresh() # UI-Bereich neu bauen 【1】 + + diff --git a/gui/styles.py b/gui/styles.py new file mode 100644 index 0000000..23cfda8 --- /dev/null +++ b/gui/styles.py @@ -0,0 +1,9 @@ +# styles.py +STYLES = { + 'header': 'text-4xl font-bold text-blue-600', + 'h1': 'text-2xl font-bold text-blue-600', + 'h2': 'text-1xl font-bold text-blue-600', + 'text': 'text-base text-slate-800', + 'hint': 'text-sm text-slate-500 italic', + 'error': 'text-sm text-red-600 font-medium', +} diff --git a/main.py b/main.py index 5f9e19d..18cd8c1 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,20 @@ -from nicegui import ui +from multiprocessing import Process +from gui.gui_dashboard import create_ui, run_ui +import time -ui.label('Hello NiceGUI on Mint') -ui.run() \ No newline at end of file +def worker(): + while True: + #print('worker alive') + time.sleep(2) + +def start_server(): + create_ui() + run_ui() + +if __name__ == '__main__': + # nur hier Worker starten + Process(target=worker, daemon=True).start() + start_server() +elif __name__ == '__mp_main__': + # NiceGUI/Reload/Multiprocessing-Serverprozess: nur Server starten + start_server() diff --git a/workers/ping_worker.py b/workers/ping_worker.py new file mode 100644 index 0000000..e31fa75 --- /dev/null +++ b/workers/ping_worker.py @@ -0,0 +1,6 @@ +import time + +def ping_loop(): + while True: + # hier später echte Arbeit + time.sleep(5)