Coder Social home page Coder Social logo

odengraphqt's Introduction

OdenGraphQt

OdenGraphQt is a fork of jchanvfx NodeGraphQt, a node graph UI framework for PySide6 that can be implemented and re-purposed into applications.

Changes from NodeGraphQt

  • PySide6 compatibility (I have not tested PyQt6) courtesy of jowr and rajkundu
  • Alternative port accept/reject connection
  • Partial type hints for IDE type checker (e.g. PyCharm)
  • Minor code reformat, tweaks and comments for code readability

Install

For now, please install as editable package. I'll be publishing to PyPI after I'm done with a few rounds of sanity testing.

I highly advise using virtual environment when developing any tools/applications.

Assuming you're on Windows and using command prompt. Git Bash user please change the path to Unix style.

  1. Clone this repository (e.g. D:\Repo\OdenGraphQt)
  2. Navigate to the Python app code you wish to integrate OdenGraphQt (e.g. D:\Tools\MyAwesomePipelineTool)
  3. Run pip install -e D:\Repo\OdenGraphQt
  4. ???
  5. Profit You can start importing OdenGraphQt module in your Python app code.

Documentation

Please refer to jchanvfx excellent documentation at https://chantonic.com/NodeGraphQt/api/index.html

I'll update this section in the near future after re-configuring the sphinx_doc_build.yml.

See the basic_example.py script to get started or accept_reject_example.py for the alternative port accept/reject connection logic.

Why Oden? なぜおでんなのか?

Oden is delicious. おでんはおいしいです。

Real answer: I need to have a different namespace and Node can be rearranged as Oden by shifting N to the back.

odengraphqt's People

Contributors

jchanvfx avatar arnochenfx avatar hueyyeng avatar davidlatwe avatar wilecoyote2015 avatar cesioarg avatar manuelkoester avatar mara004 avatar jakubjezek001 avatar jowr avatar thimic avatar samyhocine avatar jlalleve-ea avatar riggitlikeyoudiggit avatar rajkundu avatar richardfrangenberg avatar filip-dobrocky avatar ahmedhussein89 avatar jdpatt avatar erol444 avatar graygoose124 avatar nallath avatar kb1rd avatar ray-barrett avatar bigroy avatar aboellinger avatar

Stargazers

BleethNie avatar  avatar Dian Yordanov avatar

Watchers

 avatar

odengraphqt's Issues

Bad Escape regex when using tab_search

Accidentally key in slash. Need to sanitize the key input or handling.

re.error: bad escape (end of pattern) at position 12
Traceback (most recent call last):
  File "d:\projects\work\nodegraphqt\NodeGraphQt\widgets\tab_search.py", line 195, in _on_text_changed
    action_names = self._fuzzy_finder(text, self._actions.keys())
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\projects\work\nodegraphqt\NodeGraphQt\widgets\tab_search.py", line 174, in _fuzzy_finder
    regex = re.compile(pattern)
            ^^^^^^^^^^^^^^^^^^^

Alternative Accept/Reject Port Type Checker

Just thinking out loud on constraining Accept Port Type with the Node without going through many layers of abstraction...

  1. Mutate PortItem to know which port that is accepted.
  2. In NodeViewer that calls _validate_accept_connection, maybe can consider to check if the mutated PortItem has the alternative constraint before falling back to the usual flow.
  3. This alternative checking should be able to use the BaseNode identifier value to check against the "inherited base class of the Node" instead of adding every single possible subclasses node.

Random code for others to visualise what's going on:

class BasePublishNode(BaseNode):
    __identifier__ = "publish"
    allow_multiple_write = False

    def __init__(self):
        super().__init__()
        port = self.add_output(
            "write",
            multi_output=self.allow_multiple_write,
        )
        port_type = {
            "port_name": "src",
            "port_type": PortTypeEnum.IN.value,
            "node_type": f"{self.__identifier__}.PublishWriteNode",
        }
        self.add_accept_port_type(
            port,
            port_type,
        )


class PublishFileActionNode(BasePublishNode):
    NODE_NAME = "Publish File"
    allow_multiple_write = False


class PublishFileToManyActionNode(BasePublishNode):
    NODE_NAME = "Publish File to Many"
    allow_multiple_write = True


class PublishWriteNode(BaseNode):
    __identifier__ = "publish"
    NODE_NAME = "Publish Write"

    def __init__(self):
        super().__init__()
        self.set_color(164, 130, 0)
        self.add_text_input("write", "Path:")

        port = self.add_input("src", multi_input=False)
        port_type = {
            "port_name": "write",
            "port_type": PortTypeEnum.OUT.value,
            "node_type": f"publish.PublishFileToManyActionNode",  # Issue lies over here
        }
        self.add_accept_port_type(
            port,
            port_type,
        )

We have a situation where for BasePublishNode, the accept constraints for the write output port works fine assuming PublishWriteNode is the only node that take cares of the write path.

This works when trying to connect the write output port to any input of any nodes and it will fail to connect (the expected behaviour).

The MAJOR CONCERN here is that for PublishWriteNode, the src input port CAN BE CONNECTED TO ANY PORT IF WE DON'T SPECIFY ANY CONSTRAINTS. This leads to the situation above where if we want to add the constraint for any nodes that subclasses BasePublishNode, we need to keep adding each subclasses node to the acceptable port type.

Continuing from the above example code snippet:

        port = self.add_input("src", multi_input=False)
        port_type = {
            "port_name": "write",
            "port_type": PortTypeEnum.OUT.value,
            "node_type": f"publish.PublishFileToManyActionNode",  # First subclass
        }
        self.add_accept_port_type(
            port,
            port_type,
        )
       port_type = {
            "port_name": "write",
            "port_type": PortTypeEnum.OUT.value,
            "node_type": f"publish.PublishFileActionNode",  # Second subclass
        }
        self.add_accept_port_type(
            port,
            port_type,
        )
        # ... keep adding port type as required and that obviously start to lead into clunky code maintenance

Nearly forgot that any code fixes should also apply to Reject Port Checker logic...

NodeItem._set_text_color too many arguments

Hmm somehow this eludes me when trying to load from saved session.

  File "awesome\pipeline\tools", line 223, in _populate
    self.deserialize_session(nodegraph)
  File "d:\projects\work\odengraphqt\OdenGraphQt\base\graph.py", line 1859, in deserialize_session
    self._deserialize(layout_data)
  File "d:\projects\work\odengraphqt\OdenGraphQt\base\graph.py", line 1788, in _deserialize
    self.add_node(node, n_data.get('pos'))
  File "d:\projects\work\odengraphqt\OdenGraphQt\base\graph.py", line 1342, in add_node
    node.update()
  File "d:\projects\work\odengraphqt\OdenGraphQt\base\node.py", line 218, in update
    self.view.from_dict(settings)
  File "d:\projects\work\odengraphqt\OdenGraphQt\qgraphics\node_base.py", line 1047, in from_dict
    super(NodeItem, self).from_dict(node_dict)
  File "d:\projects\work\odengraphqt\OdenGraphQt\qgraphics\node_abstract.py", line 260, in from_dict
    setattr(self, name, value)
  File "d:\projects\work\odengraphqt\OdenGraphQt\qgraphics\node_base.py", line 865, in text_color
    self._set_text_color(color)
  File "d:\projects\work\odengraphqt\OdenGraphQt\qgraphics\node_base.py", line 305, in _set_text_color
    text_color = QtGui.QColor(*color)
                 ^^^^^^^^^^^^^^^^^^^^
TypeError: PySide6.QtGui.QColor.__init__(): too many arguments

Not mission critical but something to keep track here since Jira board is not public.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.