.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/guis/imgui_append.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_append.py: ImGUI append to windows ======================= You can append imgui elements to an existing window, including the subplot toolbar. .. GENERATED FROM PYTHON SOURCE LINES 7-49 .. image-sg:: /_gallery/guis/images/sphx_glr_imgui_append_001.webp :alt: imgui append :srcset: /_gallery/guis/images/sphx_glr_imgui_append_001.webp :class: sphx-glr-single-img .. code-block:: Python # test_example = true import numpy as np import fastplotlib as fpl from imgui_bundle import imgui, icons_fontawesome_6 as fa figure = fpl.Figure(size=(700, 560)) figure[0, 0].add_line(np.random.rand(100), colors="r", name="line") # create an edge window @figure.add_imgui_window(location="right", size=200, title="controls") def gui(fig): if imgui.button("randomize"): fig[0, 0]["line"].data[:, 1] = np.random.rand(100) # append more elements to the same window @figure.append_imgui_window(location="right") def more(fig): line = fig[0, 0]["line"] _, line.thickness = imgui.slider_float("thickness", v=line.thickness, v_min=2.0, v_max=50.0) # append a button to the subplot toolbar that toggles axes visibility @figure[0, 0].append_imgui_window(location="toolbar") def toolbar_extra(subplot): imgui.same_line() _, subplot.axes.visible = imgui.checkbox(fa.ICON_FA_RULER_COMBINED, subplot.axes.visible) if imgui.is_item_hovered(0): imgui.set_tooltip("Axes visibility") figure.show(maintain_aspect=False) # 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.120 seconds) .. _sphx_glr_download__gallery_guis_imgui_append.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_append.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: imgui_append.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_