33 You can adapt this file completely to your liking, but it should at least
44 contain the root `toctree` directive.
55
6- mpl-gui Documentation
7- =====================
6+ =======================
7+ mpl-gui Documentation
8+ =======================
89
910.. toctree ::
1011 :maxdepth: 2
@@ -14,7 +15,7 @@ mpl-gui Documentation
1415
1516
1617Motivation
17- ----------
18+ ==========
1819
1920This project is a prototype space for overhauling the GUI event loop management
2021tools that Matplotlib provides in pyplot.
@@ -35,7 +36,7 @@ Python.
3536
3637
3738Examples
38- --------
39+ ========
3940
4041.. highlight :: python
4142
@@ -49,8 +50,8 @@ If you want to be sure that this code does not secretly depend on pyplot run ::
4950which will prevent pyplot from being imported!
5051
5152
52- show
53- ++++
53+ showing
54+ -------
5455
5556The core of the API is `~.show ` ::
5657
@@ -65,31 +66,33 @@ The core of the API is `~.show` ::
6566
6667
6768which will show both figures and block until they are closed. As part of the
68- "showing" process, the correct `
69+ "showing" process, the correct GUI objects will be created, put on the
70+ screen, and the event loop for the host GUI framework is run.
6971
7072
71- blocking
72- ++++++++
73+ blocking (or not)
74+ +++++++++++++++++
7375
74- Similar to ``plt.ion`` and ``plt.ioff ``, we provide ``mg.ion() `` and
75- ``mg.ioff() `` which have identical semantics. Thus :::
76+ Similar to `plt.ion<matplotlib.pyplot.ion> ` and
77+ `plt.ioff<matplotlib.pyplot.ioff> `, we provide `mg.ion()<mpl_gui.ion> ` and
78+ `mg.ioff()<mpl_gui.ioff> ` which have identical semantics. Thus ::
7679
7780 import mpl_gui as mg
7881 from matplotlib.figure import Figure
7982
8083 mg.ion()
81-
84+ print(mg.is_interactive())
8285 fig = Figure()
8386
8487 mg.show([fig]) # will not block
8588
8689 mg.ioff()
87-
90+ print(mg.is_interactive())
8891 mg.show([fig]) # will block!
8992
9093
91- As with `` plt.show `` , you can explicitly control the blocking behavior of
92- `` mg.show ` ` via the *block * keyword argument ::
94+ As with `plt.show<matplotlib.pyplot.show> ` , you can explicitly control the
95+ blocking behavior of ` mg.show<.show> ` via the *block * keyword argument ::
9396
9497 import mpl_gui as mg
9598 from matplotlib.figure import Figure
@@ -100,8 +103,12 @@ As with ``plt.show``, you can explicitly control the blocking behavior of
100103 mg.show([fig], block=True) # will always block
101104
102105
106+ The interactive state is shared Matplotlib and can also be controlled with
107+ `matplotlib.interactive ` and queried via `matplotlib.is_interactive `.
108+
109+
103110Figure and Axes Creation
104- ++++++++++++++++++++++++
111+ ------------------------
105112
106113In analogy with `matplotlib.pyplot ` we also provide `~mpl_gui.figure `,
107114`~mpl_gui.subplots ` and `~mpl_gui.subplot_mosaic ` ::
@@ -113,14 +120,14 @@ In analogy with `matplotlib.pyplot` we also provide `~mpl_gui.figure`,
113120
114121 mg.show([fig1, fig2, fig3])
115122
116- If `` mpl_gui `` is in "interactive mode",`~ mpl_gui.figure`,
117- `mpl_gui.subplots ` and ` mpl_gui. subplot_mosaic ` will automatically put the new Figure in a window on the
118- screen.
123+ If `mpl_gui ` is in "interactive mode", ` mpl_gui.figure `, ` mpl_gui.subplots ` and
124+ `mpl_gui.subplot_mosaic ` will automatically put the new Figure in a window on
125+ the screen (but not run the event loop) .
119126
120127
121128
122129FigureRegistry
123- ++++++++++++++
130+ --------------
124131
125132In the above examples it is the responsibility of the user to keep track of the
126133`~matplotlib.figure.Figure ` instances that are created. If the user does not keep a hard
@@ -170,7 +177,7 @@ a dictionary mapping the Figures' labels to each Figure ::
170177 fr.by_label['B'] is figB
171178
172179FigureContext
173- +++++++++++++
180+ -------------
174181
175182A very common use case is to make several figures and then show them all
176183together at the end. To facilitate this we provide a sub-class of
@@ -188,3 +195,17 @@ track of the created figures and shows them on exit ::
188195This will create 3 figures and block on ``__exit__ ``. The blocking
189196behavior depends on ``mg.is_interacitve() `` (and follow the behavior of
190197``mg.show `` or can explicitly controlled via the *block * keyword argument).
198+
199+
200+ Selecting the GUI toolkit
201+ -------------------------
202+
203+ `mpl_gui ` makes use of `Matplotlib backends
204+ <https://matplotlib.org/stable/users/explain/backends.html> `_ for actually
205+ providing the GUI bindings. Analagous to `matplotlib.use ` and
206+ `matplotlib.pyplot.switch_backend ` `mpl_gui ` provides
207+ `mpl_gui.select_gui_toolkit ` to select which GUI toolkit is used.
208+ `~mpl_gui.select_gui_toolkit ` has the same fall-back behavior as
209+ `~matplotlib.pyplot ` and stores its state in :rc: `backend `. `mpl_gui ` will
210+ consistently co-exist with `matplotlib.pyplot ` managed Figures in the same
211+ process.
0 commit comments