hoffstadt / DearPyGui

Dear PyGui: A fast and powerful Graphical User Interface Toolkit for Python with minimal dependencies

Home Page:https://dearpygui.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: Adding DearPyGui to existing imgui C++ application with an embedded Python interpreter

sebasth opened this issue · comments

Is there a way to use this library in existing C++ imgui project. I have an embedded Python interpreter in my program and would like to call python code from C++ to draw additional gui widgets, something like:

my_python_gui.py

def my_py_gui():
    with dpg.window(label="Example Window"):
            dpg.add_text("Hello world")
            dpg.add_button(label="Save", callback=save_callback)
            dpg.add_input_text(label="string")
            dpg.add_slider_float(label="float")

and rendering loop in C++ (with pybind11):

...

ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
...
// C++ imgui
...
// Python imgui (assuming the above python script previously loaded)
py::exec("my_py_gui()");
...
ImGui::Render();