#๐Ÿ”’ PyQt6 SVG missmatch

18 messages ยท Page 1 of 1 (latest)

hardy coral
#

left is what pyqt6 widget looks like, right is what svg looks like

the svg is manually made
how do i make left the same as right ? (code below)

from PyQt6.QtWidgets import QApplication, QWidget, QMainWindow, QHBoxLayout
from PyQt6.QtSvgWidgets import QSvgWidget


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setMinimumWidth(200)
        self.setMinimumHeight(200)

        layout = QHBoxLayout()

        #polygon = QLabel()
        #polygon.setPixmap(QPixmap("resources/hexagon.svg", ))
        polygon = QSvgWidget("resources/hexagon.svg")

        layout.addWidget(polygon)

        widget = QWidget()
        widget.setLayout(layout)

        self.setCentralWidget(widget)


app = QApplication([])
main_window = MainWindow()
main_window.show()
app.exec()
teal bloomBOT
#

@hardy coral

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

stiff sky
hardy coral
#

what does that limit exactly ? instruction limit ?

#

i can send the svg code here if needed

stiff sky
hardy coral
#

well only instructions im using are svg polygon line g

#

if this isnt lying to me it should all be supported

stiff sky
#

!paste

teal bloomBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

hardy coral
#
<?xml version="1.0"?>
<svg  width="200" height="200" viewBox="-100 -100 200 200" xmlns="http://www.w3.org/2000/svg"> 
    <g stroke-width="2" stroke="#FFFFFF" fill-opacity="0.5">
        <line x1=" 100" y1="      0" x2="0" y2="0"/>
        <line x1="  50" y1=" 86.602" x2="0" y2="0"/>
        <line x1=" -50" y1=" 86.602" x2="0" y2="0"/>
        <line x1="-100" y1="  1.224" x2="0" y2="0"/>
        <line x1=" -50" y1="-86.602" x2="0" y2="0"/>
        <line x1="  50" y1="-86.602" x2="0" y2="0"/>
    </g>
    <g stroke-width="0" fill="#FFF000" fill-opacity="0.4" transform=" scale(0.39215686274)">
        <polygon points = "0 0, 100 0, 50 86.602"/>
    </g>
    <g stroke-width="3" stroke="#FFFFFF" fill="#A0A0A0" fill-opacity="0.3" transform="">
        <polygon points =
            "
             100 0,  50  86.602, -50 86.602
            -100 1.224, -50 -86.602, 50 -86.602
            "
        />
    </g>
    <g stroke-width="2" stroke="#808080" fill-opacity="0" transform=" scale(0.75)">
        <polygon points =
            "
             100 0,  50  86.602, -50 86.602
            -100 1.224, -50 -86.602, 50 -86.602
            "
        />
    </g>
    <g stroke-width="3" stroke="#808080" fill-opacity="0" transform=" scale(0.50)">
        <polygon points =
            "
             100 0,  50  86.602, -50 86.602
            -100 1.224, -50 -86.602, 50 -86.602
            "
        />
    </g>
    <g stroke-width="4" stroke="#808080" fill-opacity="0" transform=" scale(0.25)">
        <polygon points =
            "
             100 0,  50  86.602, -50 86.602
            -100 1.224, -50 -86.602, 50 -86.602
            "
        />
    </g>
    <line stroke-width="4" stroke="#FFF000" x1="100" y1="0" x2="50" y2="86.602" transform=" scale(0.39215686274)"/>
</svg>
#

i can send it as file if u prefer

stiff sky
#

Yeah, all properties seem to be supported so I'm not sure what's happening here (though I'm not at a place where I can test this unfortunately). For now, you could either bring in a different SVG renderer and use QPainter with it or you could simply use the Qt Web Engine which, yes, is probably overkill but since it's Chromium it should support more of SVG.

hardy coral
teal bloomBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.