.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/guis/imgui_decorator.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr__gallery_guis_imgui_decorator.py: ImGUI decorator =============== You can quickly create imgui UIs using a decorator. .. GENERATED FROM PYTHON SOURCE LINES 7-43 .. image-sg:: /_gallery/guis/images/sphx_glr_imgui_decorator_001.webp :alt: imgui decorator :srcset: /_gallery/guis/images/sphx_glr_imgui_decorator_001.webp :class: sphx-glr-single-img .. code-block:: Python # test_example = false import numpy as np import fastplotlib as fpl from imgui_bundle import imgui np.random.seed(0) xs = np.linspace(0, 2 * np.pi, 100) figure = fpl.Figure(size=(700, 560)) figure[0, 0].add_line(np.column_stack([xs, np.sin(xs)]), thickness=3, name="sine") # the decorated function draws the imgui elements # it optionally takes the figure as its only argument @figure.add_imgui_window(location="right", size=200, title="controls") def gui(fig): line = fig[0, 0]["sine"] changed, thickness = imgui.slider_float("thickness", v=line.thickness, v_min=2.0, v_max=50.0) if changed: line.thickness = thickness if imgui.button("randomize"): line.data[:, 1] = np.random.rand(100) figure.show() # NOTE: fpl.loop.run() should not be used for interactive sessions # See the "JupyterLab and IPython" section in the user guide if __name__ == "__main__": print(__doc__) fpl.loop.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.123 seconds) .. _sphx_glr_download__gallery_guis_imgui_decorator.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: imgui_decorator.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: imgui_decorator.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_