node_editor_widget Module

A module containing NodeEditorWidget class

class nodeeditor.node_editor_widget.NodeEditorWidget(parent: Optional[PyQt5.QtWidgets.QWidget] = None)

Bases: PyQt5.QtWidgets.QWidget

Parameters

parent (QWidget) – parent widget

Instance Attributes

  • filename - currently graph’s filename or None

Scene_class

alias of nodeeditor.node_scene.Scene

GraphicsView_class

alias of nodeeditor.node_graphics_view.QDMGraphicsView

initUI()

Set up this NodeEditorWidget with its layout, Scene and QDMGraphicsView

isModified()bool

Has the Scene been modified?

Returns

True if the Scene has been modified

Return type

bool

isFilenameSet()bool

Do we have a graph loaded from file or are we creating a new one?

Returns

True if filename is set. False if it is a new graph not yet saved to a file

Return type

‘’bool’’

getSelectedItems()list

Shortcut returning Scene’s currently selected items

Returns

list of QGraphicsItems

Return type

list[QGraphicsItem]

hasSelectedItems()bool

Is there something selected in the nodeeditor.node_scene.Scene?

Returns

True if there is something selected in the Scene

Return type

bool

canUndo()bool

Can Undo be performed right now?

Returns

True if we can undo

Return type

bool

canRedo()bool

Can Redo be performed right now?

Returns

True if we can redo

Return type

bool

getUserFriendlyFilename()str

Get user friendly filename. Used in the window title

Returns

just a base name of the file or ‘New Graph’

Return type

str

fileNew()

Empty the scene (create new file)

fileLoad(filename: str)

Load serialized graph from JSON file

Parameters

filename (str) – file to load

fileSave(filename: Optional[str] = None)

Save serialized graph to JSON file. When called with an empty parameter, we won’t store/remember the filename.

Parameters

filename (str) – file to store the graph

addNodes()

Testing method to create 3 Nodes with 3 Edges connecting them

addCustomNode()

Testing method to create a custom Node with custom content

addDebugContent()

Testing method to put random QGraphicsItems and elements into QGraphicsScene