8000 Test timers and (a bit) key_press_event for interactive backends. · matplotlib/matplotlib@2926881 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2926881

Browse files
committed
Test timers and (a bit) key_press_event for interactive backends.
1 parent b5391ce commit 2926881

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

.travis.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ env:
4646
- secure: RgJI7BBL8aX5FTOQe7xiXqWHMxWokd6GNUWp1NUV2mRLXPb9dI0RXqZt3UJwKTAzf1z/OtlHDmEkBoTVK81E9iUxK5npwyyjhJ8yTJmwfQtQF2n51Q1Ww9p+XSLORrOzZc7kAo6Kw6FIXN1pfctgYq2bQkrwJPRx/oPR8f6hcbY=
4747
- secure: E7OCdqhZ+PlwJcn+Hd6ns9TDJgEUXiUNEI0wu7xjxB2vBRRIKtZMbuaZjd+iKDqCKuVOJKu0ClBUYxmgmpLicTwi34CfTUYt6D4uhrU+8hBBOn1iiK51cl/aBvlUUrqaRLVhukNEBGZcyqAjXSA/Qsnp2iELEmAfOUa92ZYo1sk=
4848
- secure: "dfjNqGKzQG5bu3FnDNwLG8H/C4QoieFo4PfFmZPdM2RY7WIzukwKFNT6kiDfOrpwt+2bR7FhzjOGlDECGtlGOtYPN8XuXGjhcP4a4IfakdbDfF+D3NPIpf5VlE6776k0VpvcZBTMYJKNFIMc7QPkOwjvNJ2aXyfe3hBuGlKJzQU="
49+
# Variables controlling Python dependencies.
4950
- CYCLER=cycler
5051
- DATEUTIL=python-dateutil
5152
- NOSE=
@@ -56,12 +57,15 @@ env:
5657
- PYTEST_COV=pytest-cov
5758
- PYTEST_PEP8=
5859
- SPHINX=sphinx
59-
- OPENBLAS_NUM_THREADS=1
60+
# Variables controlling the test run.
61+
- DELETE_FONT_CACHE=
62+
- NO_AT_BRIDGE=1 # Necessary for GTK3 interactive test.
6063
- NPROC=2
61-
- RUN_PEP8=
64+
- OPENBLAS_NUM_THREADS=1
65+
- PYTHONFAULTHANDLER=1
6266
- PYTEST_ARGS="-rawR --maxfail=50 --timeout=300 --durations=25 --cov-report= --cov=lib -n $NPROC"
6367
- PYTHON_ARGS=
64-
- DELETE_FONT_CACHE=
68+
- RUN_PEP8=
6569

6670
matrix:
6771
include:

lib/matplotlib/backends/backend_wx.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,9 +663,6 @@ def do_nothing(*args, **kwargs):
663663

664664
self.macros = {} # dict from wx id to seq of macros
665665

666-
def Destroy(self, *args, **kwargs):
667-
wx.Panel.Destroy(self, *args, **kwargs)
668-
669666
def Copy_to_Clipboard(self, event=None):
670667
"copy bitmap of canvas to system clipboard"
671668
bmp_obj = wx.BitmapDataObject()

lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,24 @@ def _get_testable_interactive_backends():
3030
return backends
3131

3232

33+
# 1. Going through a timer rather than directly calling key_press_event("q") in
34+
# the draw_event handler is necessary on wx (where the widget is otherwise
35+
# deleted too early.
36+
# 2. Calling key_press_event via the base class rather than as
37+
# fig.canvas.key_press_event is necessary on gtk3 (which redefines
38+
# key_press_event with a different signature).
3339
_test_script = """\
3440
import sys
3541
from matplotlib import pyplot as plt
42+
from matplotlib.backend_bases import FigureCanvasBase
3643
3744
fig = plt.figure()
3845
ax = fig.add_subplot(111)
39-
ax.plot([1,2,3], [1,3,1])
40-
fig.canvas.mpl_connect("draw_event", lambda event: sys.exit())
46+
ax.plot([0, 1])
47+
timer = fig.canvas.new_timer(1)
48+
timer.add_callback(FigureCanvasBase.key_press_event, fig.canvas, "q")
49+
# Trigger quitting upon draw.
50+
fig.canvas.mpl_connect("draw_event", lambda event: timer.start())
4151
plt.show()
4252
"""
4353

0 commit comments

Comments
 (0)
0