Skip to content
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

Rename "qt4" to "qt" #1043

Merged
merged 2 commits into from
Apr 20, 2023
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
4 changes: 0 additions & 4 deletions .github/workflows/bleeding-edge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,25 @@ jobs:
- name: Run kiva test suite (Linux)
env:
PYTHONFAULTHANDLER: 1
ETS_QT4_IMPORTS: 1
run: xvfb-run python -m unittest discover -v kiva
if: matrix.os == 'ubuntu-latest'
working-directory: ${{ runner.temp }}
- name: Run kiva test suite (not Linux)
env:
PYTHONFAULTHANDLER: 1
ETS_QT4_IMPORTS: 1
run: python -m unittest discover -v kiva
if: matrix.os != 'ubuntu-latest'
working-directory: ${{ runner.temp }}
- name: Run enable test suite (Linux)
env:
PYTHONFAULTHANDLER: 1
ETS_QT4_IMPORTS: 1
# kiva agg requires at least 15-bit color depth.
run: xvfb-run --server-args="-screen 0 1024x768x24" python -m unittest discover -v enable
if: matrix.os == 'ubuntu-latest'
working-directory: ${{ runner.temp }}
- name: Run enable test suite (not Linux)
env:
PYTHONFAULTHANDLER: 1
ETS_QT4_IMPORTS: 1
run: python -m unittest discover -v enable
if: matrix.os != 'ubuntu-latest'
working-directory: ${{ runner.temp }}
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/test-with-pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,25 @@ jobs:
- name: Run kiva test suite (Linux)
env:
PYTHONFAULTHANDLER: 1
ETS_QT4_IMPORTS: 1
run: xvfb-run python -m unittest discover -v kiva
if: matrix.os == 'ubuntu-latest'
working-directory: ${{ runner.temp }}
- name: Run kiva test suite (not Linux)
env:
PYTHONFAULTHANDLER: 1
ETS_QT4_IMPORTS: 1
run: python -m unittest discover -v kiva
if: matrix.os != 'ubuntu-latest'
working-directory: ${{ runner.temp }}
- name: Run enable test suite (Linux)
env:
PYTHONFAULTHANDLER: 1
ETS_QT4_IMPORTS: 1
# kiva agg requires at least 15-bit color depth.
run: xvfb-run --server-args="-screen 0 1024x768x24" python -m unittest discover -v enable
if: matrix.os == 'ubuntu-latest'
working-directory: ${{ runner.temp }}
- name: Run enable test suite (not Linux)
env:
PYTHONFAULTHANDLER: 1
ETS_QT4_IMPORTS: 1
run: python -m unittest discover -v enable
if: matrix.os != 'ubuntu-latest'
working-directory: ${{ runner.temp }}
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Enable/Kiva also have the following requirements:
.. rubric:: Optional:

- `apptools <https://pypi.org/project/apptools/>`_
- (Qt backend) `PySide <https://pypi.org/project/PySide>`_ or `PyQt4 <https://pypi.org/project/PyQt4>`_
- (Qt backend) `PySide2, PySide6 <https://pypi.org/project/PySide>`_ or `PyQt5 <https://pypi.org/project/PyQt5>`_
- (WX backend) `WxPython <https://pypi.org/project/wxPython/>`_
- (SVG backend) `PyParsing <https://pypi.org/project/pyparsing>`_
- (PDF backend) `ReportLab Toolkit <https://www.reportlab.com/dev/install/version_3_and_up/>`_
Expand Down
14 changes: 7 additions & 7 deletions ci/edmtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@
}

environment_vars = {
'pyside2': {'ETS_TOOLKIT': 'qt4', 'QT_API': 'pyside2'},
'pyside6': {'ETS_TOOLKIT': 'qt4', 'QT_API': 'pyside6'},
'pyqt5': {'ETS_TOOLKIT': 'qt4', 'QT_API': 'pyqt5'},
'pyqt6': {'ETS_TOOLKIT': 'qt4', 'QT_API': 'pyqt6'},
'pyside2': {'ETS_TOOLKIT': 'qt', 'QT_API': 'pyside2'},
'pyside6': {'ETS_TOOLKIT': 'qt', 'QT_API': 'pyside6'},
'pyqt5': {'ETS_TOOLKIT': 'qt', 'QT_API': 'pyqt5'},
'pyqt6': {'ETS_TOOLKIT': 'qt', 'QT_API': 'pyqt6'},
'wx': {'ETS_TOOLKIT': 'wx'},
'null': {'ETS_TOOLKIT': 'null.image'},
}
Expand Down Expand Up @@ -267,10 +267,10 @@ def docs(runtime, toolkit, environment):
enable_ignore = " ".join([
"enable/gcbench",
"enable/null",
"enable/qt4",
"enable/savage/trait_defs/ui/qt4",
"enable/qt",
"enable/savage/trait_defs/ui/qt",
"enable/savage/trait_defs/ui/wx",
"enable/trait_defs/ui/qt4",
"enable/trait_defs/ui/qt",
"enable/trait_defs/ui/wx",
"enable/wx",
"*/tests",
Expand Down
File renamed without changes.
47 changes: 17 additions & 30 deletions enable/qt4/base_window.py → enable/qt/base_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import warnings

# Qt imports.
from pyface.qt import QtCore, QtGui, QtOpenGL, is_qt4, is_qt5, qt_api
from pyface.qt import QtCore, QtGui, QtOpenGL, is_qt5, qt_api

# Enthought library imports.
from enable.abstract_window import AbstractWindow
Expand All @@ -43,8 +43,6 @@
)


is_qt4 = QtCore.__version_info__[0] <= 4

# QtOpenGLWidgets is not currently exposed in pyface.qt
if qt_api == "pyside6":
from PySide6.QtOpenGLWidgets import QOpenGLWidget
Expand Down Expand Up @@ -313,8 +311,6 @@ def closeEvent(self, event):
def paintEvent(self, event):
super().paintEvent(event)
self.handler.paintEvent(event)
if is_qt4:
self.swapBuffers()

def resizeEvent(self, event):
super().resizeEvent(event)
Expand Down Expand Up @@ -457,7 +453,7 @@ def _create_mouse_event(self, event):
# If the event (if there is one) doesn't contain the mouse position,
# modifiers and buttons then get sensible defaults.
try:
if is_qt4 or is_qt5:
if is_qt5:
x = event.x()
y = event.y()
else:
Expand All @@ -478,29 +474,20 @@ def _create_mouse_event(self, event):
# we treat wheel events like mouse events.
if isinstance(event, QtGui.QWheelEvent):
degrees_per_step = 15.0
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)
delta = event.pixelDelta()
if delta.x() == 0 and delta.y() == 0: # pixelDelta is optional
delta = event.angleDelta()
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:
delta = event.pixelDelta()
if delta.x() == 0 and delta.y() == 0: # pixelDelta is optional
delta = event.angleDelta()
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"
mouse_wheel = mouse_wheel_delta[1] / float(
8 * degrees_per_step
)
mouse_wheel_axis = "vertical"
else:
mouse_wheel = 0
mouse_wheel_delta = (0, 0)
Expand Down Expand Up @@ -554,11 +541,11 @@ def _create_drag_event(self, event):
)

try:
from traitsui.qt4.clipboard import PyMimeData
from traitsui.qt.clipboard import PyMimeData
except ImportError:
# traitsui isn't available, warn and just make mimedata available
# on event
warnings.warn("traitsui.qt4 is unavailable", ImportWarning)
warnings.warn("traitsui.qt is unavailable", ImportWarning)
obj = None
else:
mimedata = PyMimeData.coerce(mimedata)
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions enable/qt4/constants.py → enable/qt/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
]

if len(pointer_names) != len(pointer_shapes):
warnings.warn("The Qt4 toolkit backend pointer map is out of sync!")
warnings.warn("The Qt toolkit backend pointer map is out of sync!")

POINTER_MAP = dict(zip(pointer_names, pointer_shapes))

Expand Down Expand Up @@ -143,7 +143,7 @@
}

# Add all of the other keys registered by Qt.
# This should work for both PySide and PyQt4.
# This should work for both PySide and PyQt.
for enum_name in dir(QtCore.Qt):
if enum_name.startswith("Key_"):
enum = getattr(QtCore.Qt, enum_name)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion enable/qt4/toolkit.py → enable/qt/toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ def wrapped(name):
return wrapped


toolkit = _wrapper(Toolkit("enable", "qt4", "enable.qt4"))
toolkit = _wrapper(Toolkit("enable", "qt", "enable.qt"))
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
# -----------------------------------------------------------------------------
import os.path

from pyface.qt import QtCore, QtGui
from traits.api import Bool, Any, Str
from traitsui.qt4.editor import Editor
try:
from traitsui.qt.editor import Editor
except ModuleNotFoundError:
from traitsui.qt4.editor import Editor
Comment on lines +20 to +23
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this PR's change force us to use a traitsui which doesn't have a qt4 subpackage?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's currently backward compatible because it was low effort to do that (only 3-4 places needed try/excepts to achieve it) and it simplifies releasing.


from pyface.qt import QtCore, QtGui

# add the Qt's installed dir plugins to the library path so the iconengines
# plugin will be found:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@

from enable.savage.svg.document import SVGDocument

from traitsui.qt4.editor import Editor
try:
from traitsui.qt.editor import Editor
except ModuleNotFoundError:
from traitsui.qt4.editor import Editor

from pyface.qt import QtCore, QtSvg

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,10 @@ def setUp(self):
self.window._size = (600, 600)

def test_vertical_mouse_wheel(self):
from pyface.qt import QtCore, QtGui, is_qt4, is_qt5

from pyface.qt import QtCore, QtGui, is_qt5

# create and mock a mouse wheel event
if is_qt4:
qt_event = QtGui.QWheelEvent(
QtCore.QPoint(0, 0), # pos
200, # delta
QtCore.Qt.NoButton, # buttons
QtCore.Qt.NoModifier, # modifiers
QtCore.Qt.Vertical, # orient
)
elif is_qt5:
if is_qt5:
qt_event = QtGui.QWheelEvent(
QtCore.QPoint(0, 0), # pos
self.window.control.mapToGlobal(QtCore.QPoint(0, 0)), # globalPos
Expand Down Expand Up @@ -89,18 +80,10 @@ def test_vertical_mouse_wheel(self):
self.assertEqual(self.tool.event.mouse_wheel_delta, (0, 200))

def test_horizontal_mouse_wheel(self):
from pyface.qt import QtCore, QtGui, is_qt4, is_qt5
from pyface.qt import QtCore, QtGui, is_qt5

# create and mock a mouse wheel event
if is_qt4:
qt_event = QtGui.QWheelEvent(
QtCore.QPoint(0, 0), # pos
200, # delta
QtCore.Qt.NoButton, # buttons
QtCore.Qt.NoModifier, # modifiers
QtCore.Qt.Horizontal, # orient
)
elif is_qt5:
if is_qt5:
qt_event = QtGui.QWheelEvent(
QtCore.QPoint(0, 0), # pos
self.window.control.mapToGlobal(QtCore.QPoint(0, 0)), # globalPos
Expand Down Expand Up @@ -133,18 +116,10 @@ def test_horizontal_mouse_wheel(self):
self.assertEqual(self.tool.event.mouse_wheel_delta, (200, 0))

def test_vertical_mouse_wheel_without_pixel_delta(self):
from pyface.qt import QtCore, QtGui, is_qt4, is_qt5
from pyface.qt import QtCore, QtGui, is_qt5

# create and mock a mouse wheel event
if is_qt4:
qt_event = QtGui.QWheelEvent(
QtCore.QPoint(0, 0), # pos
200, # delta
QtCore.Qt.NoButton, # buttons
QtCore.Qt.NoModifier, # modifiers
QtCore.Qt.Vertical, # orient
)
elif is_qt5:
if is_qt5:
qt_event = QtGui.QWheelEvent(
QtCore.QPoint(0, 0), # pos
self.window.control.mapToGlobal(QtCore.QPoint(0, 0)), # globalPos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from enable.window import Window

try:
from enable.qt4.scrollbar import NativeScrollBar
from enable.qt.scrollbar import NativeScrollBar
except Exception:
NativeScrollBar = None

Expand All @@ -26,15 +26,18 @@
class ScrollBarTest(unittest.TestCase):
def setUp(self):
from pyface.qt.QtGui import QApplication
from pyface.ui.qt4.util.event_loop_helper import EventLoopHelper
try:
from pyface.ui.qt.util.event_loop_helper import EventLoopHelper
except ModuleNotFoundError:
from pyface.ui.qt4.util.event_loop_helper import EventLoopHelper

qt_app = QApplication.instance()
if qt_app is None:
qt_app = QApplication([])
self.qt_app = qt_app

if NativeScrollBar is None:
raise unittest.SkipTest("Qt4 NativeScrollbar not available.")
raise unittest.SkipTest("Qt NativeScrollbar not available.")
self.gui = GUI()
self.event_loop_helper = EventLoopHelper(gui=self.gui, qt_app=qt_app)
self.container = Container(position=[0, 0], bounds=[600, 600])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
# Thanks for using Enthought open source!
""" Defines the various RGBA color editors and the color editor factory, for
the Qt4 user interface toolkit.
the Qt user interface toolkit.
"""

# -----------------------------------------------------------------------------
Expand All @@ -27,8 +27,8 @@

# Note: The ToolkitEditorFactory class imported from color_editor is a
# subclass of the abstract ToolkitEditorFactory class
# (in traitsui.api) with qt4-specific methods defined.
# We need to override the implementations of the qt4-specific methods here.
# (in traitsui.api) with qt-specific methods defined.
# We need to override the implementations of the qt-specific methods here.

try:
from traitsui.qt.color_editor import (
Expand All @@ -41,13 +41,13 @@
)

# -----------------------------------------------------------------------------
# The PyQt4 ToolkitEditorFactory class:
# The Qt ToolkitEditorFactory class:
# -----------------------------------------------------------------------------


class ToolkitEditorFactory(BaseColorToolkitEditorFactory):

def to_qt4_color(self, editor):
def to_qt_color(self, editor):
""" Gets the PyQt color equivalent of the object trait.
"""
try:
Expand All @@ -61,7 +61,7 @@ def to_qt4_color(self, editor):
c = QtGui.QColor(color)
return c

def from_qt4_color(self, color):
def from_qt_color(self, color):
""" Gets the application equivalent of a PyQt value.
"""
return toolkit_color_to_rgba(color)
Expand Down
2 changes: 1 addition & 1 deletion enable/trait_defs/ui/rgba_color_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
if toolkit().toolkit == "wx":
from .wx.rgba_color_editor import RGBAColorEditor
elif toolkit().toolkit.startswith("qt"):
from .qt4.rgba_color_editor import RGBAColorEditor
from .qt.rgba_color_editor import RGBAColorEditor
else:
class RGBAColorEditor(object):
""" An unimplemented toolkit object
Expand Down
Loading