Unusable APIs in Node Editor
Hello! I am currently engaged in a project utilizing the node editor in imgui_bundle. While attempting to implement a copy-paste function, I encountered the problem blow.
Platform
Python 3.12.9 imgui-bundle 1.6.2
Issue Summary
The current Python bindings for the get_selected_nodes and get_selected_links functions in the imgui_node_editor module are practically unusable due to their direct C++ parameter passing style, which does not translate well to Python.
Current API Design
# IMGUI_NODE_EDITOR_API int GetSelectedNodes(NodeId* nodes, int size); /* original C++ signature */
def get_selected_nodes(nodes: NodeId, size: int) -> int:
pass
# IMGUI_NODE_EDITOR_API int GetSelectedLinks(LinkId* links, int size); /* original C++ signature */
def get_selected_links(links: LinkId, size: int) -> int:
pass
Problem
When attempting to retrieve selected objects, I discovered that these APIs have incorrect parameter types. These functions expect a pointer to an array to be filled; however, in Python, only one NodeId is passed, which should be an array of NodeId.
Upon further examination of the API, I found that several other functions exhibit the same issue. In the C++ version, some functions use NodeId and others use NodeId*. In the Python version, both NodeId and NodeId* are translated to NodeId. LinkId and PinId also have the same problem.
Looking forward to your relpy!
Hi,
Thanks for letting me know!
This is fixed by https://github.com/pthom/imgui_bundle/commit/496f3081f5ea0e01320c9afe195561c20324307b
You should be able to download wheels at https://github.com/pthom/imgui_bundle/actions/runs/14059936680
Thanks for your quick reply! I will try it later.
I also had this problem and had to use an ugly workaround. Thanks for the fix! Do you have an estimate when the next release will be out? Technically this is a breaking change, so I'll have to remove my fix when the package updates