I'm writing an GUI application that involves rendering electrical schematics. At first i used the base matplotlib backend for it, but since it's default controls are god awful, i decided to switch to pyqtgraph, which has controls that are everything i could have ever asked for (LMB - drag, scroll wheel - zoom etc). I switched to schemdraw's svg backend to make it work with pyqtgraph, by saving the schematic into an svg and then load the image to PySide6's SVG widget embedded in pyqtgraph viewbox, but while it does render the SVG file, it doesn't render the label. I checked it in a browser and it works properly there. I put it into Inkscape and it doesn't render the label there neither. Definitely something is wrong with the way schemdraw exports the file and is there a way to fix or at least bypass it?
Versions:
Windows 10
PySide6 6.11.2
pyqtgraph 0.14.0
schemdraw 0.21
Here's the code where im trying to make this specific feature work with very basic test schematic:
from PySide6.QtWidgets import (
QApplication,
QMainWindow
)
from PySide6.QtSvgWidgets import QGraphicsSvgItem
import pyqtgraph as pg
import schemdraw
import schemdraw.elements as elm
schemdraw.use('svg')
schemdraw.svgconfig.svg2 = 'False'
schemdraw.svgconfig.text = 'path'
schemdraw.svgconfig.precision = 3
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
svgViewer = pg.GraphicsLayoutWidget()
svgViewer.setBackground(background='w')
self.setCentralWidget(svgViewer)
view = svgViewer.addViewBox()
view.setAspectLocked(True)
view.invertY(False)
self.schem = schemdraw.Drawing()
self.schem += elm.Resistor().label(r'$50 \Omega$')
self.schem.save('temp.svg')
svgItem = QGraphicsSvgItem('temp.svg')
view.addItem(svgItem)
app = QApplication()
window = MainWindow()
window.show()
app.exec()
Here's the svg file in question: