Wired components to reach qt GUI with mock data provider.
This commit is contained in:
parent
445b3b3ca1
commit
204f50f2df
31
README.md
31
README.md
@ -0,0 +1,31 @@
|
|||||||
|
# Study Dashboard
|
||||||
|
|
||||||
|
## Pakete
|
||||||
|
- PySide6
|
||||||
|
- dependency-injector
|
||||||
|
|
||||||
|
|
||||||
|
## Einrichten der Entwicklungsumgebung
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Projekt herunterladen
|
||||||
|
git clone https://git.ghostnet.selfhost.eu/spektr/study-dashboard.git
|
||||||
|
cd study-dashboard
|
||||||
|
|
||||||
|
# Virtuelle Umgebung erstellen
|
||||||
|
python -m venv .venv
|
||||||
|
|
||||||
|
# Aktivieren (Linux/macOS)
|
||||||
|
source .venv/bin/activate
|
||||||
|
|
||||||
|
# Aktivieren (Windows)
|
||||||
|
.venv\Scripts\activate
|
||||||
|
|
||||||
|
# Abhängigkeiten aktualisieren
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
## Starten
|
||||||
|
```bash
|
||||||
|
python -m src.study-dashboard.main
|
||||||
|
```
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
# Runtime dependencies
|
||||||
|
PySide6 >= 6.4
|
||||||
|
dependency-injector >= 4.41
|
||||||
|
|
||||||
|
# Development tools
|
||||||
|
# Testing & Type Checking
|
||||||
|
pytest >= 7.0
|
||||||
|
mypy >= 1.0
|
||||||
|
|
||||||
|
# Code quality & Formating
|
||||||
|
black >= 23.0
|
||||||
|
flake8 >= 6.0
|
||||||
|
# pylint
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
"""
|
||||||
|
Module:
|
||||||
|
Author: Marcel König
|
||||||
|
Description:
|
||||||
|
"""
|
||||||
|
|
||||||
|
from dependency_injector import containers, providers
|
||||||
|
from .services.data_provider import DataProvider
|
||||||
|
|
||||||
|
class ApplicationContainer(containers.DeclarativeContainer):
|
||||||
|
# Configuration
|
||||||
|
# config = providers.Configuration()
|
||||||
|
|
||||||
|
# Services
|
||||||
|
# business_service = providers.Single(
|
||||||
|
# BusinessService,
|
||||||
|
# config=config.business
|
||||||
|
# )
|
||||||
|
dataProvider = providers.Singleton(DataProvider)
|
||||||
|
|
||||||
19
src/study-dashboard/gui/main_view.py
Normal file
19
src/study-dashboard/gui/main_view.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
"""
|
||||||
|
Module: gui.mainView
|
||||||
|
|
||||||
|
Dieses Modul enthält die Hauptfenster-Definition für die Qt-basierte GUI.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from PySide6.QtWidgets import QMainWindow, QLabel
|
||||||
|
|
||||||
|
class MainView(QMainWindow):
|
||||||
|
def __init__(self, data_provider):
|
||||||
|
super().__init__()
|
||||||
|
self.setWindowTitle("Studien-Dashboard")
|
||||||
|
self.resize(800, 600)
|
||||||
|
|
||||||
|
self.data_provider = data_provider
|
||||||
|
|
||||||
|
label = QLabel(str(self.data_provider.get_all()), self)
|
||||||
|
self.setCentralWidget(label)
|
||||||
|
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
"""
|
||||||
|
Module:
|
||||||
|
Author: Marcel König
|
||||||
|
Description:
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from PySide6.QtWidgets import QApplication
|
||||||
|
from .di_container import ApplicationContainer
|
||||||
|
from .gui.main_view import MainView
|
||||||
|
|
||||||
|
def main():
|
||||||
|
container = ApplicationContainer()
|
||||||
|
# container.config.from_dict(
|
||||||
|
# {
|
||||||
|
# "business": {
|
||||||
|
# "setting1": "value1",
|
||||||
|
# "setting2": "value"
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# )
|
||||||
|
|
||||||
|
app = QApplication(sys.argv)
|
||||||
|
window = MainView(data_provider=container.dataProvider())
|
||||||
|
window.show()
|
||||||
|
|
||||||
|
sys.exit(app.exec())
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
||||||
26
src/study-dashboard/services/data_provider.py
Normal file
26
src/study-dashboard/services/data_provider.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
class DataProvider:
|
||||||
|
def __init__(self):
|
||||||
|
self._data = { "foo": { "id": "foo", "value": "bar" } }
|
||||||
|
|
||||||
|
def get_all(self):
|
||||||
|
return list(self._data.values())
|
||||||
|
|
||||||
|
def get(self, item_id):
|
||||||
|
return self._data.get(item_id, None)
|
||||||
|
|
||||||
|
def create(self, data):
|
||||||
|
self._data[data['id']] = data
|
||||||
|
return data
|
||||||
|
|
||||||
|
def update(self, item_id, data):
|
||||||
|
if item_id in self._data:
|
||||||
|
self._data[item_id].update(data)
|
||||||
|
return self._data[item_id]
|
||||||
|
return None
|
||||||
|
|
||||||
|
def delete(self, item_id):
|
||||||
|
if item_id in self._data:
|
||||||
|
del self._data[item_id]
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user