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

Implement Qt4 backend by fully reexporting Qt5 backend. #9641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Implement Qt4 backend by fully reexporting Qt5 backend.
  • Loading branch information
anntzer committed Oct 31, 2017
commit c8b3a813c3f7394c88e2b07d45c32e384f724721
33 changes: 1 addition & 32 deletions 33 lib/matplotlib/backends/backend_qt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,14 @@
unicode_literals)

import six
from six import unichr
import os
import re
import signal
import sys

from matplotlib._pylab_helpers import Gcf
from matplotlib.backend_bases import (
FigureCanvasBase, FigureManagerBase, NavigationToolbar2, TimerBase,
cursors)
from matplotlib.figure import Figure
from matplotlib.widgets import SubplotTool

from .qt_compat import QtCore, QtWidgets, _getSaveFileName, __version__

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

DEBUG = False


class FigureCanvasQT(FigureCanvasQT5):

def wheelEvent(self, event):
x = event.x()
# flipy so y=0 is bottom of canvas
y = self.figure.bbox.height - event.y()
# from QWheelEvent::delta doc
steps = event.delta()/120
if (event.orientation() == QtCore.Qt.Vertical):
FigureCanvasBase.scroll_event(self, x, y, steps)
if DEBUG:
print('scroll event: delta = %i, '
'steps = %i ' % (event.delta(), steps))


@_BackendQT5.export
class _BackendQT4(_BackendQT5):
FigureCanvas = FigureCanvasQT
pass
25 changes: 5 additions & 20 deletions 25 lib/matplotlib/backends/backend_qt4agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,10 @@

import six

from .backend_agg import FigureCanvasAgg
from .backend_qt4 import (
QtCore, _BackendQT4, FigureCanvasQT, FigureManagerQT, NavigationToolbar2QT)
from .backend_qt5agg import FigureCanvasQTAggBase
from .backend_qt5agg import (
_BackendQT5Agg, FigureCanvasQTAgg, FigureManagerQT, NavigationToolbar2QT)


class FigureCanvasQTAgg(FigureCanvasQTAggBase, FigureCanvasQT):
"""
The canvas the figure renders into. Calls the draw and print fig
methods, creates the renderers, etc...

Attributes
----------
figure : `matplotlib.figure.Figure`
A high-level Figure instance

"""


@_BackendQT4.export
class _BackendQT4Agg(_BackendQT4):
FigureCanvas = FigureCanvasQTAgg
@_BackendQT5Agg.export
class _BackendQT4Agg(_BackendQT5Agg):
pass
30 changes: 21 additions & 9 deletions 30 lib/matplotlib/backends/backend_qt5.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,27 @@ def mouseReleaseEvent(self, event):
FigureCanvasBase.button_release_event(self, x, y, button,
guiEvent=event)

def wheelEvent(self, event):
x, y = self.mouseEventCoords(event)
# from QWheelEvent::delta doc
if event.pixelDelta().x() == 0 and event.pixelDelta().y() == 0:
steps = event.angleDelta().y() / 120
else:
steps = event.pixelDelta().y()
if steps:
FigureCanvasBase.scroll_event(self, x, y, steps, guiEvent=event)
if is_pyqt5():
def wheelEvent(self, event):
x, y = self.mouseEventCoords(event)
# from QWheelEvent::delta doc
if event.pixelDelta().x() == 0 and event.pixelDelta().y() == 0:
steps = event.angleDelta().y() / 120
else:
steps = event.pixelDelta().y()
if steps:
FigureCanvasBase.scroll_event(
self, x, y, steps, guiEvent=event)
else:
def wheelEvent(self, event):
x = event.x()
# flipy so y=0 is bottom of canvas
y = self.figure.bbox.height - event.y()
# from QWheelEvent::delta doc
steps = event.delta() / 120
if event.orientation() == QtCore.Qt.Vertical:
FigureCanvasBase.scroll_event(
self, x, y, steps, guiEvent=event)

def keyPressEvent(self, event):
key = self._get_key(event)
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.