A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mpl-widget-box.readthedocs.io below:

Website Navigation


mpl_widget_box — mpl-widget-box documentation

mpl_widget_box

A simple gui widgets for matplotlib with a legend-like layout.

mpl_widget_box is a gui-neutral widgets for matplotlib, that work for any of the GUI backends. While Matplitlib does support gui-neutral widgets, it doesn’t try to be too smart with respect to layout. The mpl_widget_box try to be smarter using the OffsetBox that powers Matplotlib’s legends and annotations.

Features
A Simple Example

mpl_widget_box defines its own set of widgets. To use those widgets, you first define a list of widgets and create an instance of WidgetBoxManger which will install the widgets to an axes and control them. For simplicity, we provide a helper function of install_widgets_simple which, given a list of widgets, creates a WidgetBoxManger instance under the hood and calls relevant functions to install widgets to an axes. In most cases, a callback function should be provided which will be triggered whenever an event occurs:

import matplotlib.pyplot as plt
from mpl_widget_box import (widgets as W,
                            install_widgets_simple)

fig, ax = plt.subplots()
ax.plot([0, 1])

# Widgets to be added.
widgets = [
    W.Button("btn", "Button"),
]

# A callback function which will be bound to any button-press event.
def cb(wbm, ev, status):
    if ev.wid == "btn":
        print("Button is pressed.")

install_widgets_simple(ax, widgets, cb)

plt.show()
Install

It is still in heavy development and is not available at pypi yet. You may pip instal directly from the github repo,

References

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4