imgui-python

Dear ImGui Bundle:

  基于ImGui(支持python和pyodide绑定),让PythonC++开发人员更容易使用的框架.介绍见《开源图形用户界面库ImGui简介》。github仓库地址(2022年10月在github上发布了0.5版),文档地址

  • 即时模式GUI与Python和love-ImGui捆绑包
  • online playground(Pyodide 绑定):在浏览器中编辑和运行imgui应用。
  • pdf手册
  • 架构:
    • ImmApp :是 HelloImGui 的一个扩展,能够轻松初始化需要在启动时额外设置的 ImGuiBundle 插件,ImGui Bundle 中包含的一些库在启动时需要初始化。ImmApp 通过 AddOnParams 让这变得很简单;

    • imgui:核心库

    • implot:高级实时绘图

    • imgui_md:在imgui中兼容markdown

    • hello_imgui:快速应用例程包

    • import numpy as np
      # imgui_bundle is a package that provides several imgui-related submodules
      from imgui_bundle import (imgui,       # first we import ImGui
                                implot,      # ImPlot provides advanced real-time plotting
                                imgui_md,    # imgui_md: markdown rendering for imgui
                                hello_imgui, # hello_imgui: starter pack for imgui apps
                                immapp,      # helper to activate addons (like implot, markdown, etc.)
                                )
      
      def gui():
          # Render some markdown text
          imgui_md.render_unindented("""
          # Render an animated plot with ImPlot
          This example shows how to use `ImPlot` to render an animated plot,
          and how to use `imgui_md` to render markdown text (*this text!*).
          """)
      
          # Render an animated plot
          if implot.begin_plot(
                  title_id="Plot",
                  # size in em units (1em = height of a character)
                  size=hello_imgui.em_to_vec2(40, 20)):
              x = np.arange(0, np.pi * 4, 0.01)
              y = np.cos(x + imgui.get_time())
              implot.plot_line("y1", x, y)
              implot.end_plot()
      
          if imgui.button("Exit"):
              hello_imgui.get_runner_params().app_shall_exit = True
      
      
      def main():
          # This call is specific to the ImGui Bundle interactive manual.
          from imgui_bundle.demos_python import demo_utils
          demo_utils.set_hello_imgui_demo_assets_folder() #按assert组织工程结构
      
          # Run the app with ImPlot and markdown support
          immapp.run(gui,
                     with_implot=True,
                     with_markdown=True,
                     window_size=(700, 500))
      
      
      if __name__ == "__main__":
          main()
      imgui-bundle

       

  • 其它
posted on 2025-12-19 10:23  杰瑞鼠  阅读(2)  评论(0)    收藏  举报