pthom / imgui_bundle

Dear ImGui Bundle: an extensive set of Ready-to-use widgets and libraries, based on ImGui. Start your first app in 5 lines of code, or less. Whether you prefer Python or C++, this pack has your back!
https://pthom.github.io/imgui_bundle/
MIT License
590 stars 62 forks source link

Required initialization for imgui_node_editor? #198

Closed bgribble closed 2 months ago

bgribble commented 2 months ago

I'm trying to add an imgui_node_editor panel to my Python app. I am working from the Pip install of imgui_bundle v1.3.0. The app is using the Python SDL backend and is not using the immapp or hello_imgui frameworks, just using imgui directly.

Following the demo code, I am attempting this flow:

from imgui_bundle import imgui, imgui_node_editor as nedit

nedit.get_config().settings_file = "node-edit.json"

def render():
        imgui.begin("canvas", flags=imgui.WindowFlags_.no_collapse | imgui.WindowFlags_.no_move | imgui.WindowFlags_.no_title_bar)
        nedit.begin("canvas_editor", imgui.ImVec2(0.0, 0.0))
        nedit.end()
        imgui.end()

I'm not sure what the purpose of node-edit.json is ... is it a persistent store? In any case I have tried with it not existing, with it existing but empty, and with it existing and containing just {}

In every case, the call to nedit.begin() causes the Python process to crash hard with no diagnostic output.

Is there some other initialization magic that is required to get the node editor to be creatable?

pthom commented 2 months ago

https://github.com/pthom/imgui_bundle/blob/dcd0ccd124c139638a337e1a061b1ac1a1ae62fe/bindings/imgui_bundle/imgui_node_editor.pyi#L414-L429

bgribble commented 2 months ago

Ah, thanks! That init code was hidden in the immap C++ for the demo python programs.