leon-thomm / Ryven

Flow-based visual scripting for Python
https://ryven.org
MIT License
3.77k stars 439 forks source link

Can't import custom nodes. Does the location of Nodes.py matter? #127

Closed kevinlinxc closed 1 year ago

kevinlinxc commented 1 year ago

I copied https://github.com/leon-thomm/Ryven/blob/master/docs/node%20tutorials/doc_examples/custom_widgets/nodes.py

to a folder in my working directory.

e.g.

my-app/ ├─ nodes/ │ ├─ nodes.py ├─ .gitignore ├─ README.md

In Ryven, I click import File -> nodes.py, and nothing happens. Why? I tried defining the nodes in ~/.ryven/packages/project/nodes.py but nothing happened when I imported nodes.py still.

kevinlinxc commented 1 year ago

Ok, I just discovered the logs. It seems like the error is because I don't have a widgets.py in the same directory. I guess this is because of line 2 in the nodes.py file

kevinlinxc commented 1 year ago

Another source of confusion was that when I copied and imported the Random and Print nodes from the README, nothing happened. This was because I listed them as a tuple, which is what I thought the comment was saying:

export_nodes(
    # list your node classes here, as tuple
    (RandNode, PrintNode) # correct way would be without these parentheses
)

I think the readme is a bit unclear because it seemed at first glance like there were two parentheses here, but it was just because the example was put in parentheses. Yes, this was my bad for skimming over it so quickly, but I think it would benefit everyone if it was clearer, maybe in code blocks instead of inline.

https://github.com/leon-thomm/Ryven#readme:~:text=export_nodes(Node1%2C%20Node2%2C%20)) export_nodes(Node1, Node2, ))