Skip to content

Nodes with buttons can't be saved #491

@PastaLaPate

Description

@PastaLaPate

with a basic node with for example:

        self.add_button(
            name="force_recompute",
            label="Force Recompute",
            text="Force Recompute",
            tooltip="Click to recompute",
        )

When trying to save the graph, you get

Traceback (most recent call last):
  File "D:\Documents\Lightshow\lightshow\gui\node_editor\hotkeys\hotkey_functions.py", line 86, in save_session_as
    graph.save_session(file_path)
  File "D:\Documents\Lightshow\.venv\Lib\site-packages\NodeGraphQt\base\graph.py", line 1954, in save_session
    serialized_data = self.serialize_session()
                      ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Documents\Lightshow\.venv\Lib\site-packages\NodeGraphQt\base\graph.py", line 1918, in serialize_session
    return self._serialize(self.all_nodes())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Documents\Lightshow\.venv\Lib\site-packages\NodeGraphQt\base\graph.py", line 1755, in _serialize
    n.update_model()
  File "D:\Documents\Lightshow\.venv\Lib\site-packages\NodeGraphQt\nodes\base_node.py", line 75, in update_model
    self.model.set_property(name, widget.get_value())
  File "D:\Documents\Lightshow\.venv\Lib\site-packages\NodeGraphQt\base\model.py", line 188, in set_property
    raise NodePropertyError('No property "{}"'.format(name))
NodeGraphQt.errors.NodePropertyError: No property "force_recompute"

Workaround:
add this after the add_button

        # Fixes saving issues
        self.create_property("force_recompute", "LABEL")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions