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

   233   2   1
User Avatar
Member
113 posts
Joined: 8月 2017
オンライン
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
9417 posts
Joined: 7月 2007
オフライン
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 - 2026年1月16日 05:43:10
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
113 posts
Joined: 8月 2017
オンライン
@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