From 1e2c7d606564af5021ba68c624ea3d993706313d Mon Sep 17 00:00:00 2001
From: hagrid67 <jdhwatson@gmail.com>
Date: Thu, 16 May 2019 14:52:41 +0100
Subject: [PATCH] adding dt2.py - illustration of QT SVG render prob on windows

---
 examples/qt2.py | 78 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 examples/qt2.py

diff --git a/examples/qt2.py b/examples/qt2.py
new file mode 100644
index 00000000..60741065
--- /dev/null
+++ b/examples/qt2.py
@@ -0,0 +1,78 @@
+
+
+import sys
+from PyQt5 import QtSvg
+from PyQt5.QtWidgets import QApplication, QLabel, QMainWindow, QGridLayout, QWidget
+from PyQt5.QtCore import Qt, QByteArray
+
+from flatland.utils import svg
+
+
+# Subclass QMainWindow to customise your application's main window
+class MainWindow(QMainWindow):
+
+    def __init__(self, *args, **kwargs):
+        super(MainWindow, self).__init__(*args, **kwargs)
+
+        self.setWindowTitle("My Awesome App")
+
+        layout = QGridLayout()
+        layout.setSpacing(0)
+
+        wMain = QWidget(self)
+
+        wMain.setLayout(layout)
+
+        label = QLabel("This is a PyQt5 window!")
+
+        # The `Qt` namespace has a lot of attributes to customise
+        # widgets. See: http://doc.qt.io/qt-5/qt.html
+        label.setAlignment(Qt.AlignCenter)
+        layout.addWidget(label, 0, 0)
+
+        svgWidget = QtSvg.QSvgWidget("./svg/Gleis_vertikal.svg")
+        layout.addWidget(svgWidget, 1, 0)
+
+        if True:
+            track = svg.Track()
+
+            svgWidget = None
+            iRow = 0
+            iCol = 2
+            iArt = 0
+            nCols = 3
+            for binTrans in list(track.dSvg.keys())[:2]:
+                sSVG = track.dSvg[binTrans].to_string()
+
+                bySVG = bytearray(sSVG, encoding='utf-8')
+
+                # with open(sfPath, "r") as fIn:
+                #    sSVG = fIn.read()
+                # bySVG = bytearray(sSVG, encoding='utf-8')
+
+                svgWidget = QtSvg.QSvgWidget()
+                oQB = QByteArray(bySVG)
+
+                bSuccess = svgWidget.renderer().load(oQB)
+                # print(x0, y0, x1, y1)
+                print(iRow, iCol, bSuccess)
+                print("\n\n\n", bySVG.decode("utf-8"))
+                # svgWidget.setGeometry(x0, y0, x1, y1)
+                layout.addWidget(svgWidget, iRow, iCol)
+
+                iArt += 1
+                iRow = int(iArt / nCols)
+                iCol = iArt % nCols
+
+        # Set the central widget of the Window. Widget will expand
+        # to take up all the space in the window by default.
+        self.setCentralWidget(wMain)
+
+
+app = QApplication(sys.argv)
+
+window = MainWindow()
+window.show()
+
+app.exec_()
+
-- 
GitLab