Search - User list
Full Version: Using opdef: SVG image embedded in HDA in a PySide6 dialog?
Root » Technical Discussion » Using opdef: SVG image embedded in HDA in a PySide6 dialog?
alexmajewski
I programmed a custom pyside dialog for my HDA and used QSvgWidget to display an icon (as a widget).
QSvgWidget("path/to/image_on_my_hard_drive.svg")

I was wondering if it's possible to achieve the same result with an SVG embedded in my HDA? Alternatively, a regular pixmap or something would be okay too.
tamte
vanilla Python likely cant understand opdef:

However you can use hou. readFile() [www.sidefx.com] to read your file from opdef : section into a string and go from there
alexmajewski
@tamte I was able to do this:

from PySide6.QtSvgWidgets import QSvgWidget
from PySide6.QtCore import QByteArray

icon_data = hou.readFile("opdef:/Driver/at_deadline?IconSVG")
icon_widget = QSvgWidget()
icon_widget.load(QByteArray(icon_data))
icon_widget.setFixedSize(32, 32)

And it seems to work! Many thanks
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB