Hello community, here is the log from the commit of package python-enable for openSUSE:Factory checked in at 2019-04-30 12:59:06 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-enable (Old) and /work/SRC/openSUSE:Factory/.python-enable.new.5536 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-enable" Tue Apr 30 12:59:06 2019 rev:4 rq:697377 version:4.7.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-enable/python-enable.changes 2019-03-01 16:46:30.285820026 +0100 +++ /work/SRC/openSUSE:Factory/.python-enable.new.5536/python-enable.changes 2019-04-30 12:59:09.394160650 +0200 @@ -1,0 +2,6 @@ +Sat Apr 13 21:57:46 UTC 2019 - Christophe Giboudeaux <christophe@krop.fr> + +- Add upstream patch Port-to-pyqt5.patch to get rid of the Qt4 + dependency in python-enable. + +------------------------------------------------------------------- New: ---- Port-to-pyqt5.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-enable.spec ++++++ --- /var/tmp/diff_new_pack.6w7aHm/_old 2019-04-30 12:59:10.078161194 +0200 +++ /var/tmp/diff_new_pack.6w7aHm/_new 2019-04-30 12:59:10.082161196 +0200 @@ -28,6 +28,7 @@ Group: Development/Languages/Python Url: https://github.com/enthought/enable/ Source: https://github.com/enthought/enable/archive/%{version}.tar.gz +Patch0: Port-to-pyqt5.patch BuildRequires: %{python_module Cython} BuildRequires: %{python_module devel} BuildRequires: %{python_module numpy-devel} @@ -56,7 +57,7 @@ BuildRequires: %{python_module nose} BuildRequires: %{python_module pyface} BuildRequires: %{python_module pyparsing} -BuildRequires: %{python_module qt4} +BuildRequires: %{python_module qt5} BuildRequires: %{python_module reportlab >= 3.1} BuildRequires: %{python_module six} BuildRequires: %{python_module tk} @@ -105,7 +106,7 @@ Recommends: python-pygarrayimage Recommends: python-pyglet >= 1.1.4 Recommends: python-pyparsing -Recommends: python-qt4 +Recommends: python-qt5 Recommends: python-reportlab >= 3.1 Recommends: python-tk Provides: python-kiva = %{version} @@ -131,6 +132,7 @@ %prep %setup -q -n enable-%{version} +%patch0 -p1 sed -i -e '/^#!\//, 1d' enable/savage/compliance/*.py sed -i -e '/^#!\//, 1d' kiva/setup.py sed -i -e '/^#!\//, 1d' kiva/*/setup.py ++++++ Port-to-pyqt5.patch ++++++
From 3323236a7eb79b73802f8f02e5073e6980dc06f8 Mon Sep 17 00:00:00 2001 From: Corran Webster <cwebster@enthought.com> Date: Mon, 30 Apr 2018 09:53:51 +0100 Subject: [PATCH] Qt5 Support (#302)
* Fixes for Qt5 support. - install SWIG from EDM - add pyqt5 to edmtool - mousewheel API * Add new mouse_wheel_delta to MouseEvent * CI fixes. * Drop reference to scrollbar when scrollbar is destroyed. --- .travis.yml | 3 +- ci/edmtool.py | 15 +++++++-- enable/events.py | 1 + enable/qt4/base_window.py | 26 +++++++++++++-- enable/qt4/scrollbar.py | 6 ++++ enable/tests/qt4/mouse_wheel_test_case.py | 40 ++++++++++++++++++----- enable/tests/wx/mouse_wheel_test_case.py | 2 ++ enable/wx/base_window.py | 4 +++ 8 files changed, 82 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 732c20dd..d4e08fc9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ addons: - python-wxtools - ccache - cmake - - swig - zlib1g-dev - libpng-dev - libfreetype6-dev @@ -26,7 +25,9 @@ matrix: - env: RUNTIME=2.7 TOOLKIT=wx PILLOW='pillow' - env: RUNTIME=2.7 TOOLKIT=pyqt PILLOW='pillow' - env: RUNTIME=3.5 TOOLKIT=pyqt PILLOW='pillow' + - env: RUNTIME=3.5 TOOLKIT=pyqt5 PILLOW='pillow' - env: RUNTIME=3.6 TOOLKIT=pyqt PILLOW='pillow' + - env: RUNTIME=3.6 TOOLKIT=pyqt5 PILLOW='pillow' - env: RUNTIME=2.7 TOOLKIT=null PILLOW='pillow' - env: RUNTIME=3.5 TOOLKIT=null PILLOW='pillow' - env: RUNTIME=3.6 TOOLKIT=null PILLOW='pillow' diff --git a/ci/edmtool.py b/ci/edmtool.py index b44a64a..63297a4 100644 --- a/ci/edmtool.py +++ b/ci/edmtool.py @@ -90,8 +90,8 @@ import click supported_combinations = { '2.7': {'pyqt', 'wx', 'null'}, - '3.5': {'pyqt', 'null'}, - '3.6': {'pyqt', 'null'}, + '3.5': {'pyqt', 'pyqt5', 'null'}, + '3.6': {'pyqt', 'pyqt5', 'null'}, } dependencies = { @@ -105,16 +105,19 @@ dependencies = { "swig", "unittest2", "pypdf2", + "swig", } extra_dependencies = { 'pyqt': {'pyqt'}, + 'pyqt5': set(), 'wx': {'wxpython'}, 'null': set() } environment_vars = { 'pyqt': {'ETS_TOOLKIT': 'qt4', 'QT_API': 'pyqt'}, + 'pyqt5': {'ETS_TOOLKIT': 'qt4', 'QT_API': 'pyqt5'}, 'wx': {'ETS_TOOLKIT': 'wx'}, 'null': {'ETS_TOOLKIT': 'null.image'}, } @@ -153,8 +156,14 @@ def install(runtime, toolkit, pillow, environment): "edm run -e {environment} -- pip install {pillow}", ("edm run -e {environment} -- pip install -r ci/requirements.txt" " --no-dependencies"), - "edm run -e {environment} -- python setup.py install", ] + + # pip install pyqt5, because we don't have it in EDM yet + if toolkit == 'pyqt5': + commands.append("edm run -e {environment} -- pip install pyqt5==5.9.2") + + commands.append("edm run -e {environment} -- python setup.py install") + click.echo("Creating environment '{environment}'".format(**parameters)) execute(commands, parameters) click.echo('Done install') diff --git a/enable/events.py b/enable/events.py index 922215e7..fc7d2002 100644 --- a/enable/events.py +++ b/enable/events.py @@ -129,6 +129,7 @@ class MouseEvent(BasicEvent): right_down = ReadOnly mouse_wheel = ReadOnly mouse_wheel_axis = ReadOnly + mouse_wheel_delta = ReadOnly mouse_event_trait = Event(MouseEvent) diff --git a/enable/qt4/base_window.py b/enable/qt4/base_window.py index d5d57315..303e0d38 100644 --- a/enable/qt4/base_window.py +++ b/enable/qt4/base_window.py @@ -30,6 +30,10 @@ DRAG_RESULTS_MAP ) + +is_qt4 = (QtCore.__version_info__[0] <= 4) + + class _QtWindowHandler(object): def __init__(self, qt_window, enable_window): self._enable_window = enable_window @@ -408,12 +412,27 @@ def _create_mouse_event(self, event): # A bit crap, because AbstractWindow was written with wx in mind, and # we treat wheel events like mouse events. if isinstance(event, QtGui.QWheelEvent): - delta = event.delta() degrees_per_step = 15.0 - mouse_wheel = delta / float(8 * degrees_per_step) - mouse_wheel_axis = MOUSE_WHEEL_AXIS_MAP[event.orientation()] + if is_qt4: + delta = event.delta() + mouse_wheel = delta / float(8 * degrees_per_step) + mouse_wheel_axis = MOUSE_WHEEL_AXIS_MAP[event.orientation()] + if mouse_wheel_axis == 'horizontal': + mouse_wheel_delta = (delta, 0) + else: + mouse_wheel_delta = (0, delta) + else: + delta = event.pixelDelta() + mouse_wheel_delta = (delta.x(), delta.y()) + if abs(mouse_wheel_delta[0]) > abs(mouse_wheel_delta[1]): + mouse_wheel = mouse_wheel_delta[0] / float(8 * degrees_per_step) + mouse_wheel_axis = 'horizontal' + else: + mouse_wheel = mouse_wheel_delta[1] / float(8 * degrees_per_step) + mouse_wheel_axis = 'vertical' else: mouse_wheel = 0 + mouse_wheel_delta = (0, 0) mouse_wheel_axis = 'vertical' return MouseEvent( @@ -421,6 +440,7 @@ def _create_mouse_event(self, event): y=self._flip_y(y), mouse_wheel=mouse_wheel, mouse_wheel_axis=mouse_wheel_axis, + mouse_wheel_delta=mouse_wheel_delta, alt_down=bool(modifiers & QtCore.Qt.AltModifier), shift_down=bool(modifiers & QtCore.Qt.ShiftModifier), control_down=bool(modifiers & QtCore.Qt.ControlModifier), diff --git a/enable/qt4/scrollbar.py b/enable/qt4/scrollbar.py index 1d624313..8385d1b1 100644 --- a/enable/qt4/scrollbar.py +++ b/enable/qt4/scrollbar.py @@ -44,7 +44,9 @@ def valid_scroll_position(object, name, value): class QResizableScrollBar(QtGui.QScrollBar): + resized = QtCore.Signal() + def resizeEvent(self, event): super(QResizableScrollBar, self).resizeEvent(event) self.resized.emit() @@ -175,6 +177,7 @@ def _create_control(self, window, enable_range, value): self._control.sliderPressed.connect(self._on_slider_pressed) self._control.sliderReleased.connect(self._on_slider_released) self._control.resized.connect(self._control_resized) + self._control.destroyed.connect(self._on_destroyed) self._control.setVisible(True) def _update_control(self, enable_range, value): @@ -231,6 +234,9 @@ def _control_resized(self): self._widget_moved = True self.request_redraw() + def _on_destroyed(self): + self._control = None + #------------------------------------------------------------------------ # Basic trait event handlers #------------------------------------------------------------------------ diff --git a/enable/tests/qt4/mouse_wheel_test_case.py b/enable/tests/qt4/mouse_wheel_test_case.py index 85dccf9d..3160dad6 100644 --- a/enable/tests/qt4/mouse_wheel_test_case.py +++ b/enable/tests/qt4/mouse_wheel_test_case.py @@ -43,11 +43,22 @@ def setUp(self): def test_vertical_mouse_wheel(self): from pyface.qt import QtCore, QtGui + is_qt4 = (QtCore.__version_info__[0] <= 4) + # create and mock a mouse wheel event - qt_event = QtGui.QWheelEvent( - QtCore.QPoint(0, 0), 200, QtCore.Qt.NoButton, QtCore.Qt.NoModifier, - QtCore.Qt.Vertical - ) + if is_qt4: + qt_event = QtGui.QWheelEvent( + QtCore.QPoint(0, 0), 200, QtCore.Qt.NoButton, + QtCore.Qt.NoModifier, QtCore.Qt.Vertical + ) + else: + qt_event = QtGui.QWheelEvent( + QtCore.QPointF(0, 0), + self.window.control.mapToGlobal(QtCore.QPoint(0, 0)), + QtCore.QPoint(0, 200), QtCore.QPoint(0, 200.0/120), 200, + QtCore.Qt.Vertical, QtCore.Qt.NoButton, QtCore.Qt.NoModifier, + QtCore.Qt.ScrollUpdate + ) # dispatch event self.window._on_mouse_wheel(qt_event) @@ -55,15 +66,27 @@ def test_vertical_mouse_wheel(self): # validate results self.assertEqual(self.tool.event.mouse_wheel_axis, 'vertical') self.assertAlmostEqual(self.tool.event.mouse_wheel, 5.0/3.0) + self.assertEqual(self.tool.event.mouse_wheel_delta, (0, 200)) def test_horizontal_mouse_wheel(self): from pyface.qt import QtCore, QtGui + is_qt4 = (QtCore.__version_info__[0] <= 4) + # create and mock a mouse wheel event - qt_event = QtGui.QWheelEvent( - QtCore.QPoint(0, 0), 200, QtCore.Qt.NoButton, QtCore.Qt.NoModifier, - QtCore.Qt.Horizontal - ) + if is_qt4: + qt_event = QtGui.QWheelEvent( + QtCore.QPoint(0, 0), 200, QtCore.Qt.NoButton, + QtCore.Qt.NoModifier, QtCore.Qt.Horizontal + ) + else: + qt_event = QtGui.QWheelEvent( + QtCore.QPoint(0, 0), + self.window.control.mapToGlobal(QtCore.QPoint(0, 0)), + QtCore.QPoint(200, 0), QtCore.QPoint(200.0/120, 0), 200, + QtCore.Qt.Vertical, QtCore.Qt.NoButton, QtCore.Qt.NoModifier, + QtCore.Qt.ScrollUpdate + ) # dispatch event self.window._on_mouse_wheel(qt_event) @@ -71,3 +94,4 @@ def test_horizontal_mouse_wheel(self): # validate results self.assertEqual(self.tool.event.mouse_wheel_axis, 'horizontal') self.assertAlmostEqual(self.tool.event.mouse_wheel, 5.0/3.0) + self.assertEqual(self.tool.event.mouse_wheel_delta, (200, 0)) diff --git a/enable/tests/wx/mouse_wheel_test_case.py b/enable/tests/wx/mouse_wheel_test_case.py index 8696bbde..d149fe42 100644 --- a/enable/tests/wx/mouse_wheel_test_case.py +++ b/enable/tests/wx/mouse_wheel_test_case.py @@ -60,6 +60,7 @@ def test_vertical_mouse_wheel(self): # validate results self.assertEqual(self.tool.event.mouse_wheel_axis, 'vertical') self.assertAlmostEqual(self.tool.event.mouse_wheel, 5.0/3.0) + self.assertEqual(self.tool.event.mouse_wheel_delta, (0, 200)) def test_horizontal_mouse_wheel(self): import wx @@ -78,3 +79,4 @@ def test_horizontal_mouse_wheel(self): # validate results self.assertEqual(self.tool.event.mouse_wheel_axis, 'horizontal') self.assertAlmostEqual(self.tool.event.mouse_wheel, 5.0/3.0) + self.assertEqual(self.tool.event.mouse_wheel_delta, (200, 0)) diff --git a/enable/wx/base_window.py b/enable/wx/base_window.py index 03720745..36fe4c83 100644 --- a/enable/wx/base_window.py +++ b/enable/wx/base_window.py @@ -362,6 +362,10 @@ def _create_mouse_event ( self, event ): event.GetWheelRotation()) / (event.GetWheelDelta() or 1)) wheel_axis = MOUSE_WHEEL_AXIS_MAP[event.GetWheelAxis()] + if wheel_axis == 'horizontal': + mouse_wheel_delta = (mouse_wheel * 120/200., 0) + else: + mouse_wheel_delta = (0, mouse_wheel * 120/200.) # Note: The following code fixes a bug in wxPython that returns # 'mouse_wheel' events in screen coordinates, rather than window