node_content_widget Module

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.

class nodeeditor.node_content_widget.QDMNodeContentWidget(node: Node, parent: PyQt5.QtWidgets.QWidget = None)

Bases: PyQt5.QtWidgets.QWidget, nodeeditor.node_serializable.Serializable

Base class for representation of the Node’s graphics content. This class also provides layout for other widgets inside of a Node

Parameters
  • node (Node) – reference to the Node

  • parent (QWidget) – parent widget

Instance Attributes
  • node - reference to the Node

  • layout - QLayout container

initUI()

Sets up layouts and widgets to be rendered in QDMGraphicsNode class.

setEditingFlag(value: bool)

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 QDMGraphicsView class.

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

Parameters

value – new value for editing flag

serialize()collections.OrderedDict

Serialization method to serialize this class data into OrderedDict which can be easily stored in memory or file.

Returns

data serialized in OrderedDict

Return type

OrderedDict

deserialize(data: dict, hashmap: dict = {}, restore_id: bool = True)bool

Deserialization method which take data in python dict format with helping hashmap containing references to existing entities.

Parameters
  • data (dict) – Dictionary containing serialized data

  • hashmap (dict) – Helper dictionary containing references (by id == key) to existing objects

  • restore_id (bool) – True if we are creating new Sockets. False is useful when loading existing Sockets of which we want to keep the existing object’s id.

Returns

True if deserialization was successful, otherwise False

Return type

bool

class nodeeditor.node_content_widget.QDMTextEdit

Bases: PyQt5.QtWidgets.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 QDMNodeContentWidget

focusInEvent(event: QFocusEvent)

Example of an overridden focusInEvent to mark the start of editing

Parameters

event (QFocusEvent) – Qt’s focus event

focusOutEvent(event: QFocusEvent)

Example of an overridden focusOutEvent to mark the end of editing

Parameters

event (QFocusEvent) – Qt’s focus event