NodeGraphQt icon indicating copy to clipboard operation
NodeGraphQt copied to clipboard

Node Error State

Open uclatommy opened this issue 4 years ago • 0 comments

This allows a node to display an error state that looks like the disabled state, but with error text and the message in the tooltip. Here's an example of how to use it:

class ShowError(BaseNode):
    __identifier__ = "Viewers"
    NODE_NAME = "Display Error When Connected"

    def __init__(self):
        super().__init__()
        self.inPort = self.add_input('data')
        self.add_text_input('data', 'Data Viewer', tab='widgets')

    def on_input_connected(self, to_port, from_port):
        """Override node callback method"""
        self.run()

    def on_input_disconnected(self, to_port, from_port):
        """Override node callback method"""
        self.view.error = None
        self.set_property('data', None)

    def run(self):
        self.view.error = "This is the error message."

Any connection to this node will put it into error. Disconnect it and it will clear.

uclatommy avatar Jul 30 '21 19:07 uclatommy