From 8588eda3ce4f37824d0f2a1802e234a12525c1dc Mon Sep 17 00:00:00 2001 From: Thastertyn Date: Sun, 5 Jan 2025 00:26:46 +0100 Subject: [PATCH] [main] Initial code --- src/__init__.py | 0 src/app.py | 14 ++++++++++++++ src/models/__init__.py | 0 src/models/author.py | 12 ++++++++++++ src/ui/Main.qml | 32 ++++++++++++++++++++++++++++++++ src/ui/qmldir | 2 ++ 6 files changed, 60 insertions(+) create mode 100644 src/__init__.py create mode 100644 src/app.py create mode 100644 src/models/__init__.py create mode 100644 src/models/author.py create mode 100644 src/ui/Main.qml create mode 100644 src/ui/qmldir diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/app.py b/src/app.py new file mode 100644 index 0000000..bb3cec7 --- /dev/null +++ b/src/app.py @@ -0,0 +1,14 @@ +import sys +from PySide6.QtGui import QGuiApplication +from PySide6.QtQml import QQmlApplicationEngine + +if __name__ == "__main__": + app = QGuiApplication(sys.argv) + engine = QQmlApplicationEngine() + engine.addImportPath(sys.path[0]) + engine.loadFromModule("ui", "Main") + if not engine.rootObjects(): + sys.exit(-1) + exit_code = app.exec() + del engine + sys.exit(exit_code) \ No newline at end of file diff --git a/src/models/__init__.py b/src/models/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/models/author.py b/src/models/author.py new file mode 100644 index 0000000..a26c49e --- /dev/null +++ b/src/models/author.py @@ -0,0 +1,12 @@ +from sqlalchemy import Column, Integer, VARCHAR +from sqlalchemy.orm import relationship +from sqlalchemy.ext.declarative import declarative_base + +Base = declarative_base() + +class Author(Base): + __tablename__ = "author" + + id = Column(Integer, primary_key=True) + first_name = Column(VARCHAR(length=50)) + last_name = Column(VARCHAR(length=50)) \ No newline at end of file diff --git a/src/ui/Main.qml b/src/ui/Main.qml new file mode 100644 index 0000000..29374fa --- /dev/null +++ b/src/ui/Main.qml @@ -0,0 +1,32 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts + +Window { + width: 300 + height: 200 + visible: true + title: "Hello World" + + readonly property list texts: ["Hallo Welt", "Hei maailma", "Hola Mundo", "Привет мир"] + + function setText() { + var i = Math.round(Math.random() * 3); + text.text = texts[i]; + } + + ColumnLayout { + anchors.fill: parent + + Text { + id: text + text: "Hello World" + Layout.alignment: Qt.AlignHCenter + } + Button { + text: "Click me" + Layout.alignment: Qt.AlignHCenter + onClicked: setText() + } + } +} diff --git a/src/ui/qmldir b/src/ui/qmldir new file mode 100644 index 0000000..f41aece --- /dev/null +++ b/src/ui/qmldir @@ -0,0 +1,2 @@ +module Example +Main 254.0 Main.qml \ No newline at end of file