Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a890573

Browse filesBrowse files
authored
Merge pull request #9641 from anntzer/qt4-as-qt5
Implement Qt4 backend by fully reexporting Qt5 backend.
2 parents 024d423 + c8b3a81 commit a890573
Copy full SHA for a890573

File tree

Expand file treeCollapse file tree

3 files changed

+27
-61
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+27
-61
lines changed

‎lib/matplotlib/backends/backend_qt4.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt4.py
+1-32Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,14 @@
22
unicode_literals)
33

44
import six
5-
from six import unichr
6-
import os
7-
import re
8-
import signal
9-
import sys
10-
11-
from matplotlib._pylab_helpers import Gcf
12-
from matplotlib.backend_bases import (
13-
FigureCanvasBase, FigureManagerBase, NavigationToolbar2, TimerBase,
14-
cursors)
15-
from matplotlib.figure import Figure
16-
from matplotlib.widgets import SubplotTool
17-
18-
from .qt_compat import QtCore, QtWidgets, _getSaveFileName, __version__
195

206
from .backend_qt5 import (
217
backend_version, SPECIAL_KEYS, SUPER, ALT, CTRL, SHIFT, MODIFIER_KEYS,
228
cursord, _create_qApp, _BackendQT5, TimerQT, MainWindow, FigureManagerQT,
239
NavigationToolbar2QT, SubplotToolQt, error_msg_qt, exception_handler)
2410
from .backend_qt5 import FigureCanvasQT as FigureCanvasQT5
2511

26-
DEBUG = False
27-
28-
29-
class FigureCanvasQT(FigureCanvasQT5):
30-
31-
def wheelEvent(self, event):
32-
x = event.x()
33-
# flipy so y=0 is bottom of canvas
34-
y = self.figure.bbox.height - event.y()
35-
# from QWheelEvent::delta doc
36-
steps = event.delta()/120
37-
if (event.orientation() == QtCore.Qt.Vertical):
38-
FigureCanvasBase.scroll_event(self, x, y, steps)
39-
if DEBUG:
40-
print('scroll event: delta = %i, '
41-
'steps = %i ' % (event.delta(), steps))
42-
4312

4413
@_BackendQT5.export
4514
class _BackendQT4(_BackendQT5):
46-
FigureCanvas = FigureCanvasQT
15+
pass

‎lib/matplotlib/backends/backend_qt4agg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt4agg.py
+5-20Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,10 @@
66

77
import six
88

9-
from .backend_agg import FigureCanvasAgg
10-
from .backend_qt4 import (
11-
QtCore, _BackendQT4, FigureCanvasQT, FigureManagerQT, NavigationToolbar2QT)
12-
from .backend_qt5agg import FigureCanvasQTAggBase
9+
from .backend_qt5agg import (
10+
_BackendQT5Agg, FigureCanvasQTAgg, FigureManagerQT, NavigationToolbar2QT)
1311

1412

15-
class FigureCanvasQTAgg(FigureCanvasQTAggBase, FigureCanvasQT):
16-
"""
17-
The canvas the figure renders into. Calls the draw and print fig
18-
methods, creates the renderers, etc...
19-
20-
Attributes
21-
----------
22-
figure : `matplotlib.figure.Figure`
23-
A high-level Figure instance
24-
25-
"""
26-
27-
28-
@_BackendQT4.export
29-
class _BackendQT4Agg(_BackendQT4):
30-
FigureCanvas = FigureCanvasQTAgg
13+
@_BackendQT5Agg.export
14+
class _BackendQT4Agg(_BackendQT5Agg):
15+
pass

‎lib/matplotlib/backends/backend_qt5.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt5.py
+21-9Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,27 @@ def mouseReleaseEvent(self, event):
316316
FigureCanvasBase.button_release_event(self, x, y, button,
317317
guiEvent=event)
318318

319-
def wheelEvent(self, event):
320-
x, y = self.mouseEventCoords(event)
321-
# from QWheelEvent::delta doc
322-
if event.pixelDelta().x() == 0 and event.pixelDelta().y() == 0:
323-
steps = event.angleDelta().y() / 120
324-
else:
325-
steps = event.pixelDelta().y()
326-
if steps:
327-
FigureCanvasBase.scroll_event(self, x, y, steps, guiEvent=event)
319+
if is_pyqt5():
320+
def wheelEvent(self, event):
321+
x, y = self.mouseEventCoords(event)
322+
# from QWheelEvent::delta doc
323+
if event.pixelDelta().x() == 0 and event.pixelDelta().y() == 0:
324+
steps = event.angleDelta().y() / 120
325+
else:
326+
steps = event.pixelDelta().y()
327+
if steps:
328+
FigureCanvasBase.scroll_event(
329+
self, x, y, steps, guiEvent=event)
330+
else:
331+
def wheelEvent(self, event):
332+
x = event.x()
333+
# flipy so y=0 is bottom of canvas
334+
y = self.figure.bbox.height - event.y()
335+
# from QWheelEvent::delta doc
336+
steps = event.delta() / 120
337+
if event.orientation() == QtCore.Qt.Vertical:
338+
FigureCanvasBase.scroll_event(
339+
self, x, y, steps, guiEvent=event)
328340

329341
def keyPressEvent(self, event):
330342
key = self._get_key(event)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.