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 0000000..3d93bde Binary files /dev/null and b/__pycache__/gui.cpython-312.pyc differ diff --git a/__pycache__/gui_dashboard.cpython-312.pyc b/__pycache__/gui_dashboard.cpython-312.pyc new file mode 100644 index 0000000..8b78d31 Binary files /dev/null and b/__pycache__/gui_dashboard.cpython-312.pyc differ diff --git a/gui/__pycache__/gui_dashboard.cpython-312.pyc b/gui/__pycache__/gui_dashboard.cpython-312.pyc new file mode 100644 index 0000000..944181a Binary files /dev/null and b/gui/__pycache__/gui_dashboard.cpython-312.pyc differ diff --git a/gui/__pycache__/styles.cpython-312.pyc b/gui/__pycache__/styles.cpython-312.pyc new file mode 100644 index 0000000..ee80473 Binary files /dev/null and b/gui/__pycache__/styles.cpython-312.pyc differ 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)