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

Implot initialization on demo_docking example #174

Closed rsarwar87 closed 5 months ago

rsarwar87 commented 5 months ago

Hi I am building a set of tools for plot some data using demo_docking.py as a reference point which calls the following to trigger the context creations

hello_imgui.run(runner_params)

one of the docking window gui() calls on if implot.begin_plot("##Main", ImVec2(-1, plot_height)). however this leads to this error message: RuntimeError: IM_ASSERT( (GImPlot != nullptr) && "No current context. Did you call ImPlot::CreateContext() or ImPlot::SetCurrentContext()?" ) --- implot.cpp:2373

I tried swappin the call to hello_imgui.run with

addons = immapp.AddOnsParams()
    addons.with_markdown = True
    addons.with_implot = True

    immapp.run(runner_params, addons)
    #hello_imgui.run(runner_params)

but now getting this error:

Traceback (most recent call last):
  File "/wkspace/workspace/TS_Widget/main_docking.py", line 518, in <module>
    main()
  File "/wkspace/workspace/TS_Widget/main_docking.py", line 509, in main
    immapp.run(runner_params, addons)
RuntimeError: IM_ASSERT( SizeOfIDStack == window->IDStack.Size && "PushID/PopID or TreeNode/TreePop Mismatch!" )   ---   imgui.cpp:10409

may i ask what the correct method for initializing with implot is, in this case? immapp.run accepts with_implot=True, but i am not sure if there is such a think on hello_imgui which is needed for a docking app?

Thanks.

pthom commented 5 months ago

Hello, Swapping hello_imgui.run with immapp.run should work fine, since immapp uses hello_imgui internally, and you should be able to use ImPlot.

the issue you are seeing now is different, it is related to the use of TreeNode which may also be related to other widgets, such as CollapsingHeader. You are likely not closing one which you opened

rsarwar87 commented 5 months ago

thanks. i just realized i did not close the begin_plot.

just curious, is it possible to convert an application written in python to be easily run in a web browser using emscripten.

pthom commented 5 months ago

No, it is not possible to run a python application on the web. However, since the API are so close, it is actually easy to port code from Python to C++. I often do it in a semi automatic way with ChatGPT.