-
Notifications
You must be signed in to change notification settings - Fork 309
Open
Description
i have been fighting with it trying to get an image, including trying to make a custom widget i can't seem to manage it.... interestingly i can make an image that sorta hovers over the top... but i wanted to make it play nice and stretch the node
i should note i'm on the PyPy version, seems to be:
NodeGraphQt 0.6.43
PySide6 6.10.1
compliments on the framework btw, it acts very naturally and allows a lot with little effort, lots of bits like focus and copy paste etc all as one liners
image over top example, but not as a widget
class CustomBaseNode(BaseNode):
"""
Docstring for BaseNode2
"""
__identifier__ = 'node'
NODE_NAME = 'CustomBaseNode'
def __init__(self):
super().__init__()
def set_image(self, image_path):
"""Load and set an image for this node"""
pixmap = QtGui.QPixmap(image_path)
if not pixmap.isNull():
# Remove old pixmap if exists
if self._pixmap_item:
self.view.scene().removeItem(self._pixmap_item)
# Scale pixmap to fit
# scaled_pixmap = pixmap.scaled(64, 128, QtCore.Qt.AspectRatioMode.KeepAspectRatio,
# QtCore.Qt.TransformationMode.SmoothTransformation)
scaled_pixmap = pixmap.scaled(64, 128, QtCore.Qt.AspectRatioMode.IgnoreAspectRatio,
QtCore.Qt.TransformationMode.SmoothTransformation)
# Create pixmap item as child of node view
self._pixmap_item = QGraphicsPixmapItem(scaled_pixmap)
self._pixmap_item.setParentItem(self.view)
# Position it within the node (adjust as needed)
self._pixmap_item.setPos(10, 30)
print(f"Image loaded: {image_path}")
else:
print(f"Failed to load image: {image_path}")
Metadata
Metadata
Assignees
Labels
No labels