Hauptseite mit Fenstern und Buttons

This commit is contained in:
Daniel Nagel 2026-01-05 21:17:16 +01:00
parent f4e2aa91c6
commit b85d426bf5
10 changed files with 81 additions and 4 deletions

View File

@ -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

2
READ ME Normal file
View File

@ -0,0 +1,2 @@
source .venv/bin/activate 17:37:58
python3 main.py

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

44
gui/gui_dashboard.py Normal file
View File

@ -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】

9
gui/styles.py Normal file
View File

@ -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',
}

22
main.py
View File

@ -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()
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()

6
workers/ping_worker.py Normal file
View File

@ -0,0 +1,6 @@
import time
def ping_loop():
while True:
# hier später echte Arbeit
time.sleep(5)