Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ImGui
✓ import imgui
Top-level module is 'imgui', not 'imgui.core' or 'PyImGui'.
Minimal GLFW+OpenGL example creating a window with a main menu bar and test window.
import imgui
from imgui.integrations.glfw import GlfwRenderer
import glfw
def main():
imgui.create_context()
window = impl_glfw_init()
impl = GlfwRenderer(window)
while not glfw.window_should_close(window):
glfw.poll_events()
impl.process_inputs()
imgui.new_frame()
if imgui.begin_main_menu_bar():
if imgui.begin_menu("File", True):
clicked_quit, _ = imgui.menu_item("Quit", "Cmd+Q", False, True)
if clicked_quit:
exit(0)
imgui.end_menu()
imgui.end_main_menu_bar()
imgui.show_test_window()
imgui.render()
impl.render(imgui.get_draw_data())
impl.shutdown()
glfw.terminate()
def impl_glfw_init():
width, height = 1280, 720
window_name = "minimal ImGui/GLFW example"
if not glfw.init():
return None
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)
glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, glfw.TRUE)
window = glfw.create_window(int(width), int(height), window_name, None, None)
glfw.make_context_current(window)
if not window:
glfw.terminate()
return None
return window
if __name__ == "__main__":
main()
Upgrade
Version history
2.0.0latest on PyPI · released Apr 19, 2023
Audit
Dependencies
PyOpenGLoptionalRequired for OpenGL renderer backend.
glfwoptionalRequired for GLFW window backend.