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.SerializableBase class for representation of the Node’s graphics content. This class also provides layout for other widgets inside of a
Node- Parameters
- Instance Attributes
node - reference to the
Nodelayout -
QLayoutcontainer
-
initUI()¶ Sets up layouts and widgets to be rendered in
QDMGraphicsNodeclass.
-
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
QDMGraphicsViewclass.This is a helper function to handle keys inside nodes with
QLineEditsorQTextEdits(you can use overriddenQDMTextEditclass) and with QGraphicsView class methodkeyPressEvent.- Parameters
value – new value for editing flag
- If you are handling keyPress events by default Qt Window’s shortcuts and
-
serialize() → collections.OrderedDict¶ Serialization method to serialize this class data into
OrderedDictwhich 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
dictformat with helping hashmap containing references to existing entities.- Parameters
data (
dict) – Dictionary containing serialized datahashmap (
dict) – Helper dictionary containing references (by id == key) to existing objectsrestore_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
Trueif deserialization was successful, otherwiseFalse- Return type
bool
-
class
nodeeditor.node_content_widget.QDMTextEdit¶ Bases:
PyQt5.QtWidgets.QTextEditNote
This class is an example of a
QTextEditmodification that handles the Delete key event with an overridden Qt’skeyPressEvent(when not usingQActionsin menu or toolbar)Overridden
QTextEditwhich sends a notification about being edited to its parent’s containerQDMNodeContentWidget-
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
-