@@ -10,8 +10,10 @@ a figure to inspect your data, however there is also a full mouse and
10
10
keyboard event handling system to enable building sophisticated interactive
11
11
graphs.
12
12
13
- This page is meant to be a rapid introduction to the relevant details of
14
- integrating the matplotlib with a GUI event loop.
13
+ This page is meant to be a rapid introduction to the relevant details
14
+ of integrating the matplotlib with a GUI event loop. For further
15
+ details see `Interactive Applications using Matplotlib
16
+ <http://www.amazon.com/Interactive-Applications-using-Matplotlib-Benjamin/dp/1783988843> `__.
15
17
16
18
17
19
The GUI event loop
@@ -35,34 +37,34 @@ The python capi provides a hook, `PyOS_InputHook`, to register a
35
37
function to be run "The function will be called when Python's
36
38
interpreter prompt is about to become idle and wait for user input
37
39
from the terminal.". This hook can be used to integrate a second
38
- event loop with the python repl. Such a hooks are usually included
39
- with the python bindings for GUI toolkits and may be registered on
40
- import. IPython also includes hooks for all of the GUI frameworks
41
- supported by matplotlib. The hook functions typically exhaust
42
- all pending events on the GUI event queue, run the main loop for a
43
- short fixed amount of time, or run the event loop until a key is
44
- pressed on stdin.
40
+ event loop ( the GUI event loop) with the python input prompt loop.
41
+ Such hooks are usually included with the python bindings for GUI
42
+ toolkits and may be registered on import. IPython also includes hooks
43
+ for all of the GUI frameworks supported by matplotlib. The hook
44
+ functions typically exhaust all pending events on the GUI event queue,
45
+ run the main loop for a short fixed amount of time, or run the event
46
+ loop until a key is pressed on stdin.
45
47
46
48
matplotlib does not currently do any management of `PyOS_InputHook `
47
49
due to the wide range of ways that matplotlib is used. This
48
50
management is left to the code using matplotlib. Interactive figures,
49
51
even with matplotlib in 'interactive mode', may not work in the
50
52
vanilla python repl if an appropriate `PyOS_InputHook ` is not
51
53
registered. We suggest using ``IPython ``, which in addition to
52
- improving the command line, ensures that such a `PyOS_InptuHook `
54
+ improving the command line, ensures that such a `PyOS_InputHook `
53
55
function is registered for you GUI backend of choice.
54
56
55
57
A drawback of relying on `PyOS_InputHook ` is that the GUI event loop
56
58
is only processing events while python is otherwise idle and waiting
57
59
for user input. If you want the GUI to be responsive during long
58
60
running code it is necessary to periodically flush the GUI event
59
- queue. To achive this, almost all of the of the GUI-based ``Canvas ``
61
+ queue. To achieve this, almost all of the of the GUI-based ``Canvas ``
60
62
classes provide a `flush_event ` method. By periodically calling this
61
63
method the GUI will be updated and appear to be responsive.
62
64
63
65
In both cases, to schedule a re-draw of the figure at some point in
64
66
the future use ``fig.canvas.draw_idle() ``. This will defer the actual
65
- rendering of the figure until the GUI is ready to update it's
67
+ rendering of the figure until the GUI is ready to update its
66
68
on-screen representation.
67
69
68
70
Stale Artists
0 commit comments