Brush up the Python wizard code templates

Fix the spacing and introduce pathlib.

Change-Id: I240291d91cae7c233b2d3ec5c0dfaeede09ad47d
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
This commit is contained in:
Friedemann Kleint
2021-03-23 11:24:35 +01:00
parent b71e673bf2
commit cc92c5001b
2 changed files with 8 additions and 6 deletions

View File

@@ -1,15 +1,16 @@
# This Python file uses the following encoding: utf-8
import sys
import os
from pathlib import Path
import sys
from %{PySideVersion}.QtGui import QGuiApplication
from %{PySideVersion}.QtQml import QQmlApplicationEngine
if __name__ == "__main__":
app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
engine.load(os.path.join(os.path.dirname(__file__), "main.qml"))
engine.load(os.fspath(Path(__file__).resolve().parent / "main.qml"))
if not engine.rootObjects():
sys.exit(-1)
sys.exit(app.exec_())

View File

@@ -1,7 +1,7 @@
# This Python file uses the following encoding: utf-8
import sys
import os
from pathlib import Path
import sys
@if '%{BaseCB}' === 'QWidget'
from %{PySideVersion}.QtWidgets import QApplication, QWidget
@@ -27,12 +27,13 @@ class %{Class}:
def load_ui(self):
loader = QUiLoader()
path = os.path.join(os.path.dirname(__file__), "form.ui")
path = os.fspath(Path(__file__).resolve().parent / "form.ui")
ui_file = QFile(path)
ui_file.open(QFile.ReadOnly)
loader.load(ui_file, self)
ui_file.close()
if __name__ == "__main__":
app = QApplication([])
widget = %{Class}()