Using opdef: SVG image embedded in HDA in a PySide6 dialog?

   147   2   1
User Avatar
Member
113 posts
Joined: Aug. 2017
Offline
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.
User Avatar
Member
9415 posts
Joined: July 2007
Offline
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
Edited by tamte - Jan. 16, 2026 05:43:10
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
113 posts
Joined: Aug. 2017
Offline
@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
  • Quick Links