set_imgui_right_click#
- ImguiFigure.set_imgui_right_click(popup=None, *, window_flags=None)[source]#
Set the imgui popup that is opened by a right-click within a subplot, replaces the standard right-click menu. Can also be used as a decorator, see examples.
For a list of imgui elements see the imgui docs and the “imgui” section in the fastplotlib user guide.
- Parameters:
popup (ImguiPopup | callable, optional) – an
ImguiPopupinstance, or a function that draws imgui elements. Omit when decorating.window_flags (
imgui.WindowFlags_, optional) – imgui window flags for the popup
Examples
As a decorator:
import numpy as np import fastplotlib as fpl from imgui_bundle import imgui figure = fpl.Figure() figure[0, 0].add_line(np.random.rand(100)) @figure.set_imgui_right_click() def popup(fig): # the figure is passed if the function takes an argument if imgui.menu_item("autoscale", "", False)[0]: fig.imgui_right_click.subplot.auto_scale()
Function, the same function can be set on any number of figures, subplots or graphics:
def popup(subplot): imgui.text(f"subplot: {subplot.name}") figure[0, 0].set_imgui_right_click(popup) figure[0, 1].set_imgui_right_click(popup)
Instance:
figure.set_imgui_right_click(MyPopup())