Skip to content

Content widgets

Content widgets are the widgets drawn inside a node, and the decorators provide the node title and the collapse/expand button.

nodeeditor.node_content_widget

A module containing the base class for the Node's content graphical representation. It also contains an example of an overridden Text Widget, which can pass a notification to it's parent about being modified.

QDMNodeContentWidget

Bases: QWidget, Serializable

Base class for representation of the Node's graphics content. This class also provides layout for other widgets inside of a :py:class:~nodeeditor.node_node.Node

initUI

initUI()

Sets up layouts and widgets to be rendered in :py:class:~nodeeditor.node_graphics_node.QDMGraphicsNode class.

setEditingFlag

setEditingFlag(value)

.. note::

If you are handling keyPress events by default Qt Window's shortcuts and ``QActions``, you will not
 need to use this method.

Helper function which sets editingFlag inside :py:class:~nodeeditor.node_graphics_view.QDMGraphicsView class.

This is a helper function to handle keys inside nodes with QLineEdits or QTextEdits (you can use overridden :py:class:QDMTextEdit class) and with QGraphicsView class method keyPressEvent.

:param value: new value for editing flag

serialize

serialize()

Serialization method to serialize this class data into OrderedDict.

The content widget holds no state of its own, so there is nothing to store.

:return: data serialized in OrderedDict :rtype: OrderedDict

deserialize

deserialize(data, hashmap={}, restore_id=True)

Deserialization method which takes data in python dict format.

The content widget holds no state of its own, so there is nothing to restore and the call always succeeds.

:param data: Dictionary containing serialized data :type data: dict :param hashmap: Helper dictionary containing references (by id == key) to existing objects :type hashmap: dict :param restore_id: True if we are creating new objects. False is useful when loading existing objects of which we want to keep the existing object's id. :type restore_id: bool :return: True if deserialization was successful, otherwise False :rtype: bool

QDMTextEdit

Bases: QTextEdit

.. note::

This class is an example of a ``QTextEdit`` modification that handles the `Delete` key event with an overridden
Qt's ``keyPressEvent`` (when not using ``QActions`` in menu or toolbar)

Overridden QTextEdit which sends a notification about being edited to its parent's container :py:class:QDMNodeContentWidget

focusInEvent

focusInEvent(event)

Example of an overridden focusInEvent to mark the start of editing

:param event: Qt's focus event :type event: QFocusEvent

focusOutEvent

focusOutEvent(event)

Example of an overridden focusOutEvent to mark the end of editing

:param event: Qt's focus event :type event: QFocusEvent

nodeeditor.node_icon_content_widget

A module containing the base class for the Node's content graphical representation. It also contains an example of an overridden Text Widget, which can pass a notification to it's parent about being modified.

QDMNodeIconContentWidget

Bases: QWidget, Serializable

Base class for representation of the Node's graphics content. This class also provides layout for other widgets inside of a :py:class:~nodeeditor.node_node.Node

initUI

initUI(icon=None)

Sets up layouts and widgets to be rendered in :py:class:~nodeeditor.node_graphics_node.QDMGraphicsNode class.

setEditingFlag

setEditingFlag(value)

.. note::

If you are handling keyPress events by default Qt Window's shortcuts and ``QActions``, you will not
 need to use this method.

Helper function which sets editingFlag inside :py:class:~nodeeditor.node_graphics_view.QDMGraphicsView class.

This is a helper function to handle keys inside nodes with QLineEdits or QTextEdits (you can use overridden :py:class:QDMTextEdit class) and with QGraphicsView class method keyPressEvent.

:param value: new value for editing flag

serialize

serialize()

Serialization method to serialize this class data into OrderedDict.

:return: data serialized in OrderedDict :rtype: OrderedDict

deserialize

deserialize(data, hashmap={}, restore_id=True)

Deserialization method which takes data in python dict format.

The icon content holds no state of its own, so there is nothing to restore and the call always succeeds.

:param data: Dictionary containing serialized data :type data: dict :param hashmap: Helper dictionary containing references (by id == key) to existing objects :type hashmap: dict :param restore_id: True if we are creating new objects. False is useful when loading existing objects of which we want to keep the existing object's id. :type restore_id: bool :return: True if deserialization was successful, otherwise False :rtype: bool

QDMTextEdit

Bases: QTextEdit

.. note::

This class is an example of a ``QTextEdit`` modification that handles the `Delete` key event with an overridden
Qt's ``keyPressEvent`` (when not using ``QActions`` in menu or toolbar)

Overridden QTextEdit which sends a notification about being edited to its parent's container :py:class:QDMNodeContentWidget

focusInEvent

focusInEvent(event)

Example of an overridden focusInEvent to mark the start of editing

:param event: Qt's focus event :type event: QFocusEvent

focusOutEvent

focusOutEvent(event)

Example of an overridden focusOutEvent to mark the end of editing

:param event: Qt's focus event :type event: QFocusEvent

nodeeditor.node_icon_graphics_node

A module containing Graphics representation of :class:~nodeeditor.node_node.Node

QDMIconGraphicsNode

Bases: QGraphicsItem

Class describing Graphics representation of :class:~nodeeditor.node_node.Node

content property

content

Reference to Node Content

title property writable

title

title of this Node

:getter: current Graphics Node title :setter: stores and make visible the new title :type: str

initUI

initUI()

Set up this QGraphicsItem

initSizes

initSizes()

Set up internal attributes like width, height, etc.

initAssets

initAssets()

Initialize QObjects like QColor, QPen and QBrush

onSelected

onSelected()

Our event handling when the node was selected

doSelect

doSelect(new_state=True)

Safe version of selecting the Graphics Node. Takes care about the selection state flag used internally

:param new_state: True to select, False to deselect :type new_state: bool

itemChange

itemChange(change, value)

Refresh this node's edges when Qt moves it.

Qt moves the dragged node - and every other node in the selection - itself. Reacting to the position change Qt already reports updates the edges of exactly the nodes that moved, replacing the old per-mouse-move scan of every node in the scene.

mouseMoveEvent

mouseMoveEvent(event)

Overridden event to detect that we moved with this Node

mouseReleaseEvent

mouseReleaseEvent(event)

Overriden event to handle when we moved, selected or deselected this Node

mouseDoubleClickEvent

mouseDoubleClickEvent(event)

Overriden event for doubleclick. Resend to Node::onDoubleClicked

hoverEnterEvent

hoverEnterEvent(event)

Handle hover effect

hoverLeaveEvent

hoverLeaveEvent(event)

Handle hover effect

boundingRect

boundingRect()

Defining Qt' bounding rectangle

initTitle

initTitle()

Set up the title Graphics representation: font, color, position, etc.

setDetailState

setDetailState(state)

Apply a resolved per-element detail state.

The scene resolves its detail policy into a mapping of element key to "draw it" and hands the whole mapping over, so an application can add elements of its own to the same broadcast and read them back here. The zoom state itself rides along under the detail key.

Every child is pushed, not only the ones whose flag changed: a socket or a content proxy built after the last flip has never seen the state.

setDetailVisible

setDetailVisible(visible)

Show or hide this node's fine detail at low zoom.

The legacy entry point, kept for callers outside the scene: it drops the content widget, the floating label and the socket circles together. The scene uses :meth:setDetailState instead, which resolves each of those separately.

syncDetailVisibility

syncDetailVisibility()

Push the scene's current detail state onto every child item.

The sockets and the content proxy are built during Node.__init__, after Qt already reported this node joining the scene, so the scene's one-off broadcast never reached them - and Qt's ItemChildAddedChange hands over a base-class wrapper for an item still inside its own constructor, which has no setDetailVisible. Called from Node.__init__ once the node is fully built.

initContent

initContent()

Set up the grContent - QGraphicsProxyWidget to have a container for Graphics Content

initLabel

initLabel()

Create the floating single-line label above the node (hidden until text is set).

setLabelText

setLabelText(text)

Set label text (single-line). Empty text hides the label. No history stored.

labelText

labelText()

Return current label text.

setLabelVisible

setLabelVisible(visible)

Show/hide the label. Hidden when text is empty regardless.

isLabelVisible

isLabelVisible()

True while the label is requested visible and carries text.

setLabelOffset

setLabelOffset(offset)

Set the gap in px between node top and label bottom.

:param offset: the new gap in px :type offset: float

labelOffset

labelOffset()

Return the gap in px between node top and label bottom.

setLabelColor

setLabelColor(color)

Set the text color of the label.

:param color: the new text color :type color: QColor

setLabelFont

setLabelFont(font)

Set the font of the label and move the label to its new position.

:param font: the new font :type font: QFont

setLabelBackground

setLabelBackground(bg, border=None)

Set the background and border colors of the label box.

:param bg: background color of the label box :type bg: QColor :param border: border color of the label box :type border: QColor

paint

paint(painter, QStyleOptionGraphicsItem, widget=None)

Painting the rounded rectanglar Node

nodeeditor.node_decorators

A module containing the decorator which marks classes as automatically serializable

MakeSerializable

Registry for classes that should be automatically serialized

register classmethod

register(key='')

Class decorator to mark a class as automatically serializable

get_registered classmethod

get_registered()

Get all classes registered as automatically serializable

:return: mapping of serialize keys to the registered classes :rtype: dict

get_instance classmethod

get_instance(key, scene)

Get instance for given key and scene