diff --git a/.github/actions/install-qt-support/action.yml b/.github/actions/install-qt-support/action.yml index 15e7a22a6..66b98ab7e 100644 --- a/.github/actions/install-qt-support/action.yml +++ b/.github/actions/install-qt-support/action.yml @@ -20,6 +20,7 @@ runs: sudo apt-get install libxcb-render-util0 sudo apt-get install libxcb-xinerama0 sudo apt-get install libxcb-shape0 + sudo apt-get install libxcb-cursor0 sudo apt-get install pulseaudio sudo apt-get install libpulse-mainloop-glib0 # Needed to work around https://bugreports.qt.io/browse/PYSIDE-1547 diff --git a/.github/workflows/test-with-edm.yml b/.github/workflows/test-with-edm.yml index 3a9921bbd..8b5120eaf 100644 --- a/.github/workflows/test-with-edm.yml +++ b/.github/workflows/test-with-edm.yml @@ -8,7 +8,7 @@ name: Test with EDM -on: [pull_request, workflow_dispatch] +on: [workflow_dispatch] env: INSTALL_EDM_VERSION: 3.5.0 diff --git a/docs/source/traitsui_user_manual/adapters.rst b/docs/source/traitsui_user_manual/adapters.rst index f96d5419f..57a0d1813 100644 --- a/docs/source/traitsui_user_manual/adapters.rst +++ b/docs/source/traitsui_user_manual/adapters.rst @@ -252,7 +252,7 @@ The Qt backend allows users to completely override the rendering of cells in a TreeEditor. To do this, the TreeNode should override the :py:meth:`TreeNode.get_renderer` method to return an instance of a subclass of :py:class:`~traitsui.tree_node_renderer.AbstractTreeNodeRenderer`. -A :py:class:`~traitsui.qt4.tree_node_renderers.WordWrapRenderer` is available +A :py:class:`~traitsui.qt.tree_node_renderers.WordWrapRenderer` is available to provide basic word-wrapped layout in a cell, but user-defined subclasses can do any rendering that they want by implementing their own :py:class:`~traitsui.tree_node_renderer.AbstractTreeNodeRenderer` subclass. diff --git a/ets-demo/etstool.py b/ets-demo/etstool.py index 437bc967c..b85429e31 100644 --- a/ets-demo/etstool.py +++ b/ets-demo/etstool.py @@ -161,9 +161,9 @@ BUNDLE_NAME = f"etsdemo-{APP_BUNDLE_VERSION}.bundle" environment_vars = { - 'pyside2': {'ETS_TOOLKIT': 'qt4', 'QT_API': 'pyside2'}, - 'pyside6': {'ETS_TOOLKIT': 'qt4', 'QT_API': 'pyside6'}, - 'pyqt5': {"ETS_TOOLKIT": "qt4", "QT_API": "pyqt5"}, + 'pyside2': {'ETS_TOOLKIT': 'qt', 'QT_API': 'pyside2'}, + 'pyside6': {'ETS_TOOLKIT': 'qt', 'QT_API': 'pyside6'}, + 'pyqt5': {"ETS_TOOLKIT": "qt", "QT_API": "pyqt5"}, 'wx': {'ETS_TOOLKIT': 'wx'}, 'null': {'ETS_TOOLKIT': 'null'}, } diff --git a/etstool.py b/etstool.py index 5537c0174..cb9aa6451 100644 --- a/etstool.py +++ b/etstool.py @@ -119,8 +119,7 @@ # Required runtime dependencies. Should match pyproject.toml. dependencies = { - # temporarily get pyface from pip until EDM release - # "pyface>=7.4.1", + "pyface>=8.0", "traits", "setuptools", } @@ -192,16 +191,16 @@ #: Paths to ignore in Sphinx-apidoc doc_ignore = { - "traitsui/qt4/*", + "traitsui/qt/*", "traitsui/wx/*", "*/tests", } environment_vars = { - '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"}, + '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"}, 'wx': {'ETS_TOOLKIT': 'wx'}, 'null': {'ETS_TOOLKIT': 'null'}, } diff --git a/image_LICENSE.txt b/image_LICENSE.txt index 4397c6190..35dba24bf 100644 --- a/image_LICENSE.txt +++ b/image_LICENSE.txt @@ -29,7 +29,7 @@ traitsui/extras/images: reload.png | Nuvola run.png | Nuvola -traitsui/qt4/images: +traitsui/qt/images: closetab.png | Qt next.png | Qt previous.png | Qt diff --git a/pyproject.toml b/pyproject.toml index a3cdb66a9..85738bfaa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,15 +14,15 @@ classifiers = [ ] dependencies = [ 'traits>=6.2', - 'pyface>=7.4.1', + 'pyface>=8.0', 'importlib-metadata>=3.6; python_version<"3.8"', ] license = {file = "LICENSE.txt"} version = "8.0.0.dev0" [project.entry-points.'traitsui.toolkits'] -qt = 'traitsui.qt4:toolkit' -qt4 = 'traitsui.qt4:toolkit' +qt = 'traitsui.qt:toolkit' +qt4 = 'traitsui.qt:toolkit' wx = 'traitsui.wx:toolkit' null = 'traitsui.null:toolkit' @@ -70,6 +70,6 @@ traitsui = [ 'image/library/*.zip', 'images/*', 'wx/images/*', - 'qt4/images/*', + 'qt/images/*', 'testing/data/*', ] diff --git a/traitsui/examples/demo/Advanced/Date_range_editor_demo.py b/traitsui/examples/demo/Advanced/Date_range_editor_demo.py index 0fb84d664..f5048527d 100644 --- a/traitsui/examples/demo/Advanced/Date_range_editor_demo.py +++ b/traitsui/examples/demo/Advanced/Date_range_editor_demo.py @@ -47,7 +47,7 @@ def _date_range_changed(self): if __name__ == "__main__": - if ETSConfig.toolkit == "qt4": + if ETSConfig.toolkit in {"qt", "qt4"}: # DateRangeEditor is currently only available for qt backend. demo = DateRangeEditorDemo() demo.configure_traits() diff --git a/traitsui/examples/demo/Advanced/String_list_ui_editor.py b/traitsui/examples/demo/Advanced/String_list_ui_editor.py index 50407a3b1..dce93d2c1 100644 --- a/traitsui/examples/demo/Advanced/String_list_ui_editor.py +++ b/traitsui/examples/demo/Advanced/String_list_ui_editor.py @@ -41,7 +41,7 @@ if ETSConfig.toolkit == 'wx': from traitsui.wx.ui_editor import UIEditor else: - from traitsui.qt4.ui_editor import UIEditor + from traitsui.qt.ui_editor import UIEditor # -- Define the reusable StringListEditor class and its helper classes -------- diff --git a/traitsui/examples/demo/Advanced/Tabular_editor_demo.py b/traitsui/examples/demo/Advanced/Tabular_editor_demo.py index a51e8914c..14c90f531 100644 --- a/traitsui/examples/demo/Advanced/Tabular_editor_demo.py +++ b/traitsui/examples/demo/Advanced/Tabular_editor_demo.py @@ -195,7 +195,7 @@ def _get_MarriedPerson_spouse_text(self): adapter=ReportAdapter(), operations=['move', 'edit'], # Row titles are not supported in WX: - show_row_titles=ETSConfig.toolkit == 'qt4', + show_row_titles=(ETSConfig.toolkit in {"qt", "qt4"}), ) diff --git a/traitsui/examples/demo/Extras/LED_display.py b/traitsui/examples/demo/Extras/LED_display.py index 98b236a54..5bb0bf630 100644 --- a/traitsui/examples/demo/Extras/LED_display.py +++ b/traitsui/examples/demo/Extras/LED_display.py @@ -26,7 +26,7 @@ if ETSConfig.toolkit == 'wx': from traitsui.wx.extra.led_editor import LEDEditor else: - from traitsui.qt4.extra.led_editor import LEDEditor + from traitsui.qt.extra.led_editor import LEDEditor # Handler class for the LEDDemo class view: diff --git a/traitsui/examples/demo/Extras/Tree_editor_with_TreeNodeRenderer.py b/traitsui/examples/demo/Extras/Tree_editor_with_TreeNodeRenderer.py index b141aa6a1..3b63103db 100644 --- a/traitsui/examples/demo/Extras/Tree_editor_with_TreeNodeRenderer.py +++ b/traitsui/examples/demo/Extras/Tree_editor_with_TreeNodeRenderer.py @@ -26,7 +26,7 @@ from traitsui.api import TreeEditor, TreeNode, UItem, View, RGBColor from traitsui.tree_node_renderer import AbstractTreeNodeRenderer -from traitsui.qt4.tree_editor import WordWrapRenderer +from traitsui.qt.tree_editor import WordWrapRenderer class MyDataElement(HasTraits): diff --git a/traitsui/extras/checkbox_column.py b/traitsui/extras/checkbox_column.py index 642deac7e..14f5200ef 100644 --- a/traitsui/extras/checkbox_column.py +++ b/traitsui/extras/checkbox_column.py @@ -19,7 +19,7 @@ if ETSConfig.toolkit == "wx": from pyface.ui.wx.grid.checkbox_renderer import CheckboxRenderer elif ETSConfig.toolkit in {"qt", "qt4"}: - from ..qt4.extra.checkbox_renderer import CheckboxRenderer + from ..qt.extra.checkbox_renderer import CheckboxRenderer else: raise NotImplementedError("No checkbox renderer for backend") diff --git a/traitsui/mimedata.py b/traitsui/mimedata.py index e37b662a5..0f7cc1124 100644 --- a/traitsui/mimedata.py +++ b/traitsui/mimedata.py @@ -11,6 +11,6 @@ # Import the toolkit specific version. from traitsui.toolkit import toolkit_object -# WIP: Currently only supports qt4 backend. API might change without +# WIP: Currently only supports qt backend. API might change without # prior notification PyMimeData = toolkit_object("clipboard:PyMimeData") diff --git a/traitsui/qt/__init__.py b/traitsui/qt/__init__.py new file mode 100644 index 000000000..16293664e --- /dev/null +++ b/traitsui/qt/__init__.py @@ -0,0 +1,38 @@ +# (C) Copyright 2008-2023 Enthought, Inc., Austin, TX +# All rights reserved. +# +# This software is provided without warranty under the terms of the BSD +# license included in LICENSE.txt and may be redistributed only under +# the conditions described in the aforementioned license. The license +# is also available online at http://www.enthought.com/licenses/BSD.txt +# +# Thanks for using Enthought open source! + +# ------------------------------------------------------------------------------ +# Copyright (c) 2007, Riverbank Computing Limited +# All rights reserved. +# +# This software is provided without warranty under the terms of the BSD license. +# However, when used with the GPL version of PyQt the additional terms +# described in the PyQt GPL exception also apply + +# +# Author: Riverbank Computing Limited +# ------------------------------------------------------------------------------ + +""" Defines the concrete implementations of the traits Toolkit interface for +the PyQt user interface toolkit. +""" + +# import pyface.qt before anything else is done so the sipapi +# can be set correctly if needed +import pyface.qt + +# ---------------------------------------------------------------------------- +# Define the reference to the exported GUIToolkit object: +# ---------------------------------------------------------------------------- + +from . import toolkit + +# Reference to the GUIToolkit object for Qt. +toolkit = toolkit.GUIToolkit("traitsui", "qt", "traitsui.qt") diff --git a/traitsui/qt4/array_editor.py b/traitsui/qt/array_editor.py similarity index 100% rename from traitsui/qt4/array_editor.py rename to traitsui/qt/array_editor.py diff --git a/traitsui/qt4/array_view_editor.py b/traitsui/qt/array_view_editor.py similarity index 100% rename from traitsui/qt4/array_view_editor.py rename to traitsui/qt/array_view_editor.py diff --git a/traitsui/qt4/boolean_editor.py b/traitsui/qt/boolean_editor.py similarity index 100% rename from traitsui/qt4/boolean_editor.py rename to traitsui/qt/boolean_editor.py diff --git a/traitsui/qt4/button_editor.py b/traitsui/qt/button_editor.py similarity index 100% rename from traitsui/qt4/button_editor.py rename to traitsui/qt/button_editor.py diff --git a/traitsui/qt4/check_list_editor.py b/traitsui/qt/check_list_editor.py similarity index 100% rename from traitsui/qt4/check_list_editor.py rename to traitsui/qt/check_list_editor.py diff --git a/traitsui/qt4/clipboard.py b/traitsui/qt/clipboard.py similarity index 95% rename from traitsui/qt4/clipboard.py rename to traitsui/qt/clipboard.py index fad4f7635..d94f87fa8 100644 --- a/traitsui/qt4/clipboard.py +++ b/traitsui/qt/clipboard.py @@ -25,10 +25,7 @@ """ from pyface.qt import QtGui -try: - from pyface.ui.qt.mimedata import PyMimeData, str2bytes -except ModuleNotFoundError: - from pyface.ui.qt4.mimedata import PyMimeData, str2bytes +from pyface.ui.qt.mimedata import PyMimeData, str2bytes from traits.api import HasTraits, Instance, Property diff --git a/traitsui/qt4/code_editor.py b/traitsui/qt/code_editor.py similarity index 98% rename from traitsui/qt4/code_editor.py rename to traitsui/qt/code_editor.py index c835801c7..9f6a84a14 100644 --- a/traitsui/qt4/code_editor.py +++ b/traitsui/qt/code_editor.py @@ -27,10 +27,7 @@ from pyface.qt import QtGui from pyface.key_pressed_event import KeyPressedEvent -try: - from pyface.ui.qt.code_editor.code_widget import AdvancedCodeWidget -except ModuleNotFoundError: - from pyface.ui.qt4.code_editor.code_widget import AdvancedCodeWidget +from pyface.ui.qt.code_editor.code_widget import AdvancedCodeWidget from traits.api import ( Str, List, diff --git a/traitsui/qt4/color_editor.py b/traitsui/qt/color_editor.py similarity index 96% rename from traitsui/qt4/color_editor.py rename to traitsui/qt/color_editor.py index 2a70f8cbb..c41d3539b 100644 --- a/traitsui/qt4/color_editor.py +++ b/traitsui/qt/color_editor.py @@ -46,7 +46,7 @@ # The PyQt ToolkitEditorFactory class. # --------------------------------------------------------------------------- -## We need to add qt4-specific methods to the editor factory (since all editors +## We need to add qt-specific methods to the editor factory (since all editors ## will be accessing these functions. Making these functions global functions ## in this file does not work quite well, since we want custom editors to ## override these methods easily. @@ -55,14 +55,14 @@ class ToolkitEditorFactory(BaseToolkitEditorFactory): """PyQt editor factory for color editors.""" - def to_qt4_color(self, editor): + def to_qt_color(self, editor): """Gets the PyQt color equivalent of the object trait.""" if self.mapped: return getattr(editor.object, editor.name + "_") return getattr(editor.object, editor.name) - def from_qt4_color(self, color): + def from_qt_color(self, color): """Gets the application equivalent of a PyQt value.""" return color @@ -95,7 +95,7 @@ class SimpleColorEditor(BaseSimpleEditor): def popup_editor(self): """Invokes the pop-up editor for an object trait.""" - color = self.factory.to_qt4_color(self) + color = self.factory.to_qt_color(self) options = QtGui.QColorDialog.ColorDialogOption.ShowAlphaChannel if not self.factory.use_native_dialog: options |= QtGui.QColorDialog.ColorDialogOption.DontUseNativeDialog @@ -104,7 +104,7 @@ def popup_editor(self): ) if color.isValid(): - self.value = self.factory.from_qt4_color(color) + self.value = self.factory.from_qt_color(color) self.update_editor() def update_editor(self): @@ -144,7 +144,7 @@ def update_editor(self): def update_object_from_swatch(self, color_text): """Updates the object trait when a color swatch is clicked.""" color = QtGui.QColor(*[int(part) for part in color_text.split(",")]) - self.value = self.factory.from_qt4_color(color) + self.value = self.factory.from_qt_color(color) self.update_editor() def string_value(self, color): @@ -205,7 +205,7 @@ def string_value(self, color): def set_color(editor): """Sets the color of the specified color control.""" - color = editor.factory.to_qt4_color(editor) + color = editor.factory.to_qt_color(editor) pal = QtGui.QPalette(editor.control.palette()) pal.setColor(QtGui.QPalette.ColorRole.Base, color) diff --git a/traitsui/qt4/color_trait.py b/traitsui/qt/color_trait.py similarity index 96% rename from traitsui/qt4/color_trait.py rename to traitsui/qt/color_trait.py index cb9a78bfd..e50ce2d62 100644 --- a/traitsui/qt4/color_trait.py +++ b/traitsui/qt/color_trait.py @@ -94,13 +94,13 @@ def convert_to_color(object, name, value): # ------------------------------------------------------------------------- ### FIXME: We have declared the 'editor' to be a function instead of the -# traitsui.qt4.color_editor.ToolkitEditorFactory class, since the +# traitsui.qt.color_editor.ToolkitEditorFactory class, since the # latter is leading to too many circular imports. In the future, try to see if # there is a better way to do this. def get_color_editor(*args, **traits): - from traitsui.qt4.color_editor import ToolkitEditorFactory + from traitsui.qt.color_editor import ToolkitEditorFactory return ToolkitEditorFactory(*args, **traits) diff --git a/traitsui/qt4/compound_editor.py b/traitsui/qt/compound_editor.py similarity index 100% rename from traitsui/qt4/compound_editor.py rename to traitsui/qt/compound_editor.py diff --git a/traitsui/qt4/constants.py b/traitsui/qt/constants.py similarity index 100% rename from traitsui/qt4/constants.py rename to traitsui/qt/constants.py diff --git a/traitsui/qt4/csv_list_editor.py b/traitsui/qt/csv_list_editor.py similarity index 100% rename from traitsui/qt4/csv_list_editor.py rename to traitsui/qt/csv_list_editor.py diff --git a/traitsui/qt4/custom_editor.py b/traitsui/qt/custom_editor.py similarity index 100% rename from traitsui/qt4/custom_editor.py rename to traitsui/qt/custom_editor.py diff --git a/traitsui/qt4/data_frame_editor.py b/traitsui/qt/data_frame_editor.py similarity index 100% rename from traitsui/qt4/data_frame_editor.py rename to traitsui/qt/data_frame_editor.py diff --git a/traitsui/qt4/date_editor.py b/traitsui/qt/date_editor.py similarity index 100% rename from traitsui/qt4/date_editor.py rename to traitsui/qt/date_editor.py diff --git a/traitsui/qt4/date_range_editor.py b/traitsui/qt/date_range_editor.py similarity index 100% rename from traitsui/qt4/date_range_editor.py rename to traitsui/qt/date_range_editor.py diff --git a/traitsui/qt4/datetime_editor.py b/traitsui/qt/datetime_editor.py similarity index 100% rename from traitsui/qt4/datetime_editor.py rename to traitsui/qt/datetime_editor.py diff --git a/traitsui/qt4/directory_editor.py b/traitsui/qt/directory_editor.py similarity index 100% rename from traitsui/qt4/directory_editor.py rename to traitsui/qt/directory_editor.py diff --git a/traitsui/qt4/drop_editor.py b/traitsui/qt/drop_editor.py similarity index 97% rename from traitsui/qt4/drop_editor.py rename to traitsui/qt/drop_editor.py index 3a7efbb52..a6cc5c673 100644 --- a/traitsui/qt4/drop_editor.py +++ b/traitsui/qt/drop_editor.py @@ -60,7 +60,7 @@ def init(self, parent): drop_event_filter = _DropEventFilter(self.control) self.control.installEventFilter(drop_event_filter) - self.control._qt4_editor = self + self.control._qt_editor = self def dispose(self): """Disposes of the content of an editor.""" @@ -92,7 +92,7 @@ def eventFilter(self, source, event): def dropEvent(self, e): """Handles a Python object being dropped on the tree.""" - editor = self.parent()._qt4_editor + editor = self.parent()._qt_editor klass = editor.factory.klass @@ -119,7 +119,7 @@ def dropEvent(self, e): def dragEnterEvent(self, e): """Handles a Python object being dragged over the tree.""" - editor = self.parent()._qt4_editor + editor = self.parent()._qt_editor if editor.factory.binding: data = getattr(clipboard, "node", None) diff --git a/traitsui/qt4/editor.py b/traitsui/qt/editor.py similarity index 100% rename from traitsui/qt4/editor.py rename to traitsui/qt/editor.py diff --git a/traitsui/qt4/editor_factory.py b/traitsui/qt/editor_factory.py similarity index 100% rename from traitsui/qt4/editor_factory.py rename to traitsui/qt/editor_factory.py diff --git a/traitsui/qt4/enum_editor.py b/traitsui/qt/enum_editor.py similarity index 100% rename from traitsui/qt4/enum_editor.py rename to traitsui/qt/enum_editor.py diff --git a/traitsui/qt4/extra/__init__.py b/traitsui/qt/extra/__init__.py similarity index 100% rename from traitsui/qt4/extra/__init__.py rename to traitsui/qt/extra/__init__.py diff --git a/traitsui/qt4/extra/bounds_editor.py b/traitsui/qt/extra/bounds_editor.py similarity index 98% rename from traitsui/qt4/extra/bounds_editor.py rename to traitsui/qt/extra/bounds_editor.py index f7f8ae9d5..45f76a45b 100644 --- a/traitsui/qt4/extra/bounds_editor.py +++ b/traitsui/qt/extra/bounds_editor.py @@ -13,8 +13,8 @@ from traits.api import Float, Any, Str, Union from traitsui.editors.api import RangeEditor -from traitsui.qt4.editor import Editor -from traitsui.qt4.extra.range_slider import RangeSlider +from traitsui.qt.editor import Editor +from traitsui.qt.extra.range_slider import RangeSlider class _BoundsEditor(Editor): diff --git a/traitsui/qt4/extra/checkbox_renderer.py b/traitsui/qt/extra/checkbox_renderer.py similarity index 98% rename from traitsui/qt4/extra/checkbox_renderer.py rename to traitsui/qt/extra/checkbox_renderer.py index d33410a9c..a3f896743 100644 --- a/traitsui/qt4/extra/checkbox_renderer.py +++ b/traitsui/qt/extra/checkbox_renderer.py @@ -16,7 +16,7 @@ from pyface.qt import QtCore, QtGui # ETS imports -from traitsui.qt4.table_editor import TableDelegate +from traitsui.qt.table_editor import TableDelegate class CheckboxRenderer(TableDelegate): diff --git a/traitsui/qt4/extra/led_editor.py b/traitsui/qt/extra/led_editor.py similarity index 96% rename from traitsui/qt4/extra/led_editor.py rename to traitsui/qt/extra/led_editor.py index d16fead96..74210cd8f 100644 --- a/traitsui/qt4/extra/led_editor.py +++ b/traitsui/qt/extra/led_editor.py @@ -9,7 +9,7 @@ # Thanks for using Enthought open source! from pyface.qt import QtGui -from traitsui.qt4.editor import Editor +from traitsui.qt.editor import Editor from traitsui.basic_editor_factory import BasicEditorFactory from traits.api import Any, Undefined diff --git a/traitsui/qt4/extra/progress_renderer.py b/traitsui/qt/extra/progress_renderer.py similarity index 97% rename from traitsui/qt4/extra/progress_renderer.py rename to traitsui/qt/extra/progress_renderer.py index fea6923b2..e473a4b8e 100644 --- a/traitsui/qt4/extra/progress_renderer.py +++ b/traitsui/qt/extra/progress_renderer.py @@ -15,7 +15,7 @@ from pyface.qt import QtCore, QtGui # ETS imports -from traitsui.qt4.table_editor import TableDelegate +from traitsui.qt.table_editor import TableDelegate class ProgressRenderer(TableDelegate): diff --git a/traitsui/qt4/extra/qt_view.py b/traitsui/qt/extra/qt_view.py similarity index 100% rename from traitsui/qt4/extra/qt_view.py rename to traitsui/qt/extra/qt_view.py diff --git a/traitsui/qt4/extra/range_slider.py b/traitsui/qt/extra/range_slider.py similarity index 100% rename from traitsui/qt4/extra/range_slider.py rename to traitsui/qt/extra/range_slider.py diff --git a/traitsui/qt4/extra/table_image_renderer.py b/traitsui/qt/extra/table_image_renderer.py similarity index 98% rename from traitsui/qt4/extra/table_image_renderer.py rename to traitsui/qt/extra/table_image_renderer.py index ba902953d..83eff78d1 100644 --- a/traitsui/qt4/extra/table_image_renderer.py +++ b/traitsui/qt/extra/table_image_renderer.py @@ -17,7 +17,7 @@ # ETS imports from traits.api import Bool -from traitsui.qt4.table_editor import TableDelegate +from traitsui.qt.table_editor import TableDelegate class TableImageRenderer(TableDelegate): diff --git a/traitsui/qt4/file_editor.py b/traitsui/qt/file_editor.py similarity index 100% rename from traitsui/qt4/file_editor.py rename to traitsui/qt/file_editor.py diff --git a/traitsui/qt4/font_editor.py b/traitsui/qt/font_editor.py similarity index 94% rename from traitsui/qt4/font_editor.py rename to traitsui/qt/font_editor.py index 0fdc840ae..d54bd1d12 100644 --- a/traitsui/qt4/font_editor.py +++ b/traitsui/qt/font_editor.py @@ -63,20 +63,20 @@ # --------------------------------------------------------------------------- # The PyQtToolkitEditorFactory class. # --------------------------------------------------------------------------- -## We need to add qt4-specific methods to the editor factory, and so we create +## We need to add qt-specific methods to the editor factory, and so we create ## a subclass of the BaseToolkitEditorFactory. class ToolkitEditorFactory(BaseToolkitEditorFactory): """PyQt editor factory for font editors.""" - def to_qt4_font(self, editor): + def to_qt_font(self, editor): """Returns a QFont object corresponding to a specified object's font trait. """ return QtGui.QFont(editor.value) - def from_qt4_font(self, font): + def from_qt_font(self, font): """Gets the application equivalent of a QFont value.""" return font @@ -106,11 +106,11 @@ class SimpleFontEditor(BaseSimpleEditor): def popup_editor(self): """Invokes the pop-up editor for an object trait.""" fnt, ok = QtGui.QFontDialog.getFont( - self.factory.to_qt4_font(self), self.control + self.factory.to_qt_font(self), self.control ) if ok: - self.value = self.factory.from_qt4_font(fnt) + self.value = self.factory.from_qt_font(fnt) self.update_editor() def update_editor(self): @@ -168,7 +168,7 @@ def init(self, parent): def update_object(self): """Handles the user changing the contents of the font text control.""" self.value = str(self._font.text()) - self._set_font(self.factory.to_qt4_font(self)) + self._set_font(self.factory.to_qt_font(self)) self.update_editor() def update_object_parts(self): @@ -181,7 +181,7 @@ def update_object_parts(self): psz = int(self._point_size.currentText()) fnt.setPointSize(psz) - self.value = self.factory.from_qt4_font(fnt) + self.value = self.factory.from_qt_font(fnt) self._font.setText(self.str_value) self._set_font(fnt) @@ -190,7 +190,7 @@ def update_editor(self): """Updates the editor when the object trait changes externally to the editor. """ - font = self.factory.to_qt4_font(self) + font = self.factory.to_qt_font(self) self._bold = font.bold() self._italic = font.italic() @@ -267,7 +267,7 @@ def string_value(self, font): def set_font(editor): """Sets the editor control's font to match a specified font.""" - editor.control.setFont(editor.factory.to_qt4_font(editor)) + editor.control.setFont(editor.factory.to_qt_font(editor)) # Define the names SimpleEditor, CustomEditor, TextEditor and ReadonlyEditor diff --git a/traitsui/qt4/font_trait.py b/traitsui/qt/font_trait.py similarity index 98% rename from traitsui/qt4/font_trait.py rename to traitsui/qt/font_trait.py index fe2166425..3dd348100 100644 --- a/traitsui/qt4/font_trait.py +++ b/traitsui/qt/font_trait.py @@ -194,13 +194,13 @@ def info(self): # ------------------------------------------------------------------------- ### FIXME: We have declared the 'editor' to be a function instead of the -# traitsui.qt4.font_editor.ToolkitEditorFactory class, since the +# traitsui.qt.font_editor.ToolkitEditorFactory class, since the # latter is leading to too many circular imports. In the future, try to see if # there is a better way to do this. def get_font_editor(*args, **traits): - from traitsui.qt4.font_editor import ToolkitEditorFactory + from traitsui.qt.font_editor import ToolkitEditorFactory return ToolkitEditorFactory(*args, **traits) diff --git a/traitsui/qt4/helper.py b/traitsui/qt/helper.py similarity index 100% rename from traitsui/qt4/helper.py rename to traitsui/qt/helper.py diff --git a/traitsui/qt4/history_editor.py b/traitsui/qt/history_editor.py similarity index 100% rename from traitsui/qt4/history_editor.py rename to traitsui/qt/history_editor.py diff --git a/traitsui/qt4/html_editor.py b/traitsui/qt/html_editor.py similarity index 100% rename from traitsui/qt4/html_editor.py rename to traitsui/qt/html_editor.py diff --git a/traitsui/qt4/image_editor.py b/traitsui/qt/image_editor.py similarity index 100% rename from traitsui/qt4/image_editor.py rename to traitsui/qt/image_editor.py diff --git a/traitsui/qt4/image_enum_editor.py b/traitsui/qt/image_enum_editor.py similarity index 100% rename from traitsui/qt4/image_enum_editor.py rename to traitsui/qt/image_enum_editor.py diff --git a/traitsui/qt4/images/closetab.png b/traitsui/qt/images/closetab.png similarity index 100% rename from traitsui/qt4/images/closetab.png rename to traitsui/qt/images/closetab.png diff --git a/traitsui/qt4/images/frame.png b/traitsui/qt/images/frame.png similarity index 100% rename from traitsui/qt4/images/frame.png rename to traitsui/qt/images/frame.png diff --git a/traitsui/qt4/images/list_editor.png b/traitsui/qt/images/list_editor.png similarity index 100% rename from traitsui/qt4/images/list_editor.png rename to traitsui/qt/images/list_editor.png diff --git a/traitsui/qt4/images/next.png b/traitsui/qt/images/next.png similarity index 100% rename from traitsui/qt4/images/next.png rename to traitsui/qt/images/next.png diff --git a/traitsui/qt4/images/previous.png b/traitsui/qt/images/previous.png similarity index 100% rename from traitsui/qt4/images/previous.png rename to traitsui/qt/images/previous.png diff --git a/traitsui/qt4/instance_editor.py b/traitsui/qt/instance_editor.py similarity index 100% rename from traitsui/qt4/instance_editor.py rename to traitsui/qt/instance_editor.py diff --git a/traitsui/qt4/key_binding_editor.py b/traitsui/qt/key_binding_editor.py similarity index 100% rename from traitsui/qt4/key_binding_editor.py rename to traitsui/qt/key_binding_editor.py diff --git a/traitsui/qt4/key_event_to_name.py b/traitsui/qt/key_event_to_name.py similarity index 100% rename from traitsui/qt4/key_event_to_name.py rename to traitsui/qt/key_event_to_name.py diff --git a/traitsui/qt4/list_editor.py b/traitsui/qt/list_editor.py similarity index 100% rename from traitsui/qt4/list_editor.py rename to traitsui/qt/list_editor.py diff --git a/traitsui/qt4/list_str_editor.py b/traitsui/qt/list_str_editor.py similarity index 100% rename from traitsui/qt4/list_str_editor.py rename to traitsui/qt/list_str_editor.py diff --git a/traitsui/qt4/list_str_model.py b/traitsui/qt/list_str_model.py similarity index 100% rename from traitsui/qt4/list_str_model.py rename to traitsui/qt/list_str_model.py diff --git a/traitsui/qt4/menu.py b/traitsui/qt/menu.py similarity index 100% rename from traitsui/qt4/menu.py rename to traitsui/qt/menu.py diff --git a/traitsui/qt4/null_editor.py b/traitsui/qt/null_editor.py similarity index 100% rename from traitsui/qt4/null_editor.py rename to traitsui/qt/null_editor.py diff --git a/traitsui/qt4/progress_editor.py b/traitsui/qt/progress_editor.py similarity index 93% rename from traitsui/qt4/progress_editor.py rename to traitsui/qt/progress_editor.py index 2ccaaf9a7..ac9b8e10a 100644 --- a/traitsui/qt4/progress_editor.py +++ b/traitsui/qt/progress_editor.py @@ -13,11 +13,8 @@ from pyface.qt import QtGui, QtCore from traits.api import Instance, Int, Str -try: - from pyface.ui.qt.progress_dialog import ProgressDialog -except ModuleNotFoundError: - from pyface.ui.qt4.progress_dialog import ProgressDialog -from traitsui.qt4.editor import Editor +from pyface.ui.qt.progress_dialog import ProgressDialog +from traitsui.qt.editor import Editor class _ProgressDialog(ProgressDialog): diff --git a/traitsui/qt4/range_editor.py b/traitsui/qt/range_editor.py similarity index 100% rename from traitsui/qt4/range_editor.py rename to traitsui/qt/range_editor.py diff --git a/traitsui/qt4/rgb_color_editor.py b/traitsui/qt/rgb_color_editor.py similarity index 92% rename from traitsui/qt4/rgb_color_editor.py rename to traitsui/qt/rgb_color_editor.py index 58ec09b92..32aa2ac1c 100644 --- a/traitsui/qt4/rgb_color_editor.py +++ b/traitsui/qt/rgb_color_editor.py @@ -32,8 +32,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. from .color_editor import ToolkitEditorFactory as BaseColorToolkitEditorFactory # ------------------------------------------------------------------------- @@ -44,7 +44,7 @@ class ToolkitEditorFactory(BaseColorToolkitEditorFactory): """PyQt editor factory for color editors.""" - def to_qt4_color(self, editor): + def to_qt_color(self, editor): """Gets the PyQt color equivalent of the object trait.""" try: color = getattr(editor.object, editor.name + "_") @@ -56,7 +56,7 @@ def to_qt4_color(self, editor): return c - def from_qt4_color(self, color): + def from_qt_color(self, color): """Gets the application equivalent of a PyQt value.""" return (color.redF(), color.greenF(), color.blueF()) diff --git a/traitsui/qt4/rgb_color_trait.py b/traitsui/qt/rgb_color_trait.py similarity index 98% rename from traitsui/qt4/rgb_color_trait.py rename to traitsui/qt/rgb_color_trait.py index e2edcf208..af740ae21 100644 --- a/traitsui/qt4/rgb_color_trait.py +++ b/traitsui/qt/rgb_color_trait.py @@ -17,7 +17,7 @@ from traits.api import Trait, TraitError from traits.trait_base import SequenceTypes -from traitsui.qt4.color_trait import standard_colors +from traitsui.qt.color_trait import standard_colors # ------------------------------------------------------------------------- # Convert a number into an RGB tuple: diff --git a/traitsui/qt4/search_editor.py b/traitsui/qt/search_editor.py similarity index 100% rename from traitsui/qt4/search_editor.py rename to traitsui/qt/search_editor.py diff --git a/traitsui/qt4/set_editor.py b/traitsui/qt/set_editor.py similarity index 100% rename from traitsui/qt4/set_editor.py rename to traitsui/qt/set_editor.py diff --git a/traitsui/qt4/shell_editor.py b/traitsui/qt/shell_editor.py similarity index 100% rename from traitsui/qt4/shell_editor.py rename to traitsui/qt/shell_editor.py diff --git a/traitsui/qt4/styled_date_editor.py b/traitsui/qt/styled_date_editor.py similarity index 100% rename from traitsui/qt4/styled_date_editor.py rename to traitsui/qt/styled_date_editor.py diff --git a/traitsui/qt4/table_editor.py b/traitsui/qt/table_editor.py similarity index 99% rename from traitsui/qt4/table_editor.py rename to traitsui/qt/table_editor.py index 4bde463f3..bf3ded6f3 100644 --- a/traitsui/qt4/table_editor.py +++ b/traitsui/qt/table_editor.py @@ -1328,7 +1328,7 @@ class TableFilterEditor(HasTraits): layout="split", orientation="horizontal", ), - id="traitsui.qt4.table_editor.TableFilterEditor", + id="traitsui.qt.table_editor.TableFilterEditor", buttons=["OK", "Cancel"], kind="livemodal", resizable=True, diff --git a/traitsui/qt4/table_model.py b/traitsui/qt/table_model.py similarity index 99% rename from traitsui/qt4/table_model.py rename to traitsui/qt/table_model.py index cb460156c..1626f0ba1 100644 --- a/traitsui/qt4/table_model.py +++ b/traitsui/qt/table_model.py @@ -36,14 +36,14 @@ logger = logging.getLogger(__name__) -# Mapping for trait alignment values to qt4 horizontal alignment constants +# Mapping for trait alignment values to qt horizontal alignment constants h_alignment_map = { "left": QtCore.Qt.AlignmentFlag.AlignLeft, "center": QtCore.Qt.AlignmentFlag.AlignHCenter, "right": QtCore.Qt.AlignmentFlag.AlignRight, } -# Mapping for trait alignment values to qt4 vertical alignment constants +# Mapping for trait alignment values to qt vertical alignment constants v_alignment_map = { "top": QtCore.Qt.AlignmentFlag.AlignTop, "center": QtCore.Qt.AlignmentFlag.AlignVCenter, diff --git a/traitsui/qt4/tabular_editor.py b/traitsui/qt/tabular_editor.py similarity index 100% rename from traitsui/qt4/tabular_editor.py rename to traitsui/qt/tabular_editor.py diff --git a/traitsui/qt4/tabular_model.py b/traitsui/qt/tabular_model.py similarity index 99% rename from traitsui/qt4/tabular_model.py rename to traitsui/qt/tabular_model.py index 4cd943b9c..e8dc38bca 100644 --- a/traitsui/qt4/tabular_model.py +++ b/traitsui/qt/tabular_model.py @@ -20,7 +20,7 @@ from .clipboard import PyMimeData -# Mapping for trait alignment values to qt4 alignment values: +# Mapping for trait alignment values to qt alignment values: alignment_map = { "left": QtCore.Qt.AlignmentFlag.AlignLeft, "right": QtCore.Qt.AlignmentFlag.AlignRight, diff --git a/traitsui/qt4/tests/__init__.py b/traitsui/qt/tests/__init__.py similarity index 100% rename from traitsui/qt4/tests/__init__.py rename to traitsui/qt/tests/__init__.py diff --git a/traitsui/qt4/tests/test_color_trait.py b/traitsui/qt/tests/test_color_trait.py similarity index 99% rename from traitsui/qt4/tests/test_color_trait.py rename to traitsui/qt/tests/test_color_trait.py index ebcf1c558..cecb59c9e 100644 --- a/traitsui/qt4/tests/test_color_trait.py +++ b/traitsui/qt/tests/test_color_trait.py @@ -14,7 +14,7 @@ from pyface.color import Color as PyfaceColor from traits.api import HasStrictTraits, TraitError -from traitsui.qt4.color_trait import PyQtColor +from traitsui.qt.color_trait import PyQtColor class ObjectWithColor(HasStrictTraits): diff --git a/traitsui/qt4/tests/test_font_trait.py b/traitsui/qt/tests/test_font_trait.py similarity index 100% rename from traitsui/qt4/tests/test_font_trait.py rename to traitsui/qt/tests/test_font_trait.py diff --git a/traitsui/qt4/tests/test_helper.py b/traitsui/qt/tests/test_helper.py similarity index 97% rename from traitsui/qt4/tests/test_helper.py rename to traitsui/qt/tests/test_helper.py index 61fe0132e..2dc5f7bcc 100644 --- a/traitsui/qt4/tests/test_helper.py +++ b/traitsui/qt/tests/test_helper.py @@ -13,8 +13,8 @@ from pyface.qt import is_pyqt, qt_api, QtCore, QtGui from traitsui.tests._tools import is_mac_os, requires_toolkit, ToolkitName -from traitsui.qt4.helper import qobject_is_valid, wrap_text_with_elision -from traitsui.qt4.font_trait import create_traitsfont +from traitsui.qt.helper import qobject_is_valid, wrap_text_with_elision +from traitsui.qt.font_trait import create_traitsfont lorem_ipsum = ( diff --git a/traitsui/qt4/tests/test_tabular_model.py b/traitsui/qt/tests/test_tabular_model.py similarity index 100% rename from traitsui/qt4/tests/test_tabular_model.py rename to traitsui/qt/tests/test_tabular_model.py diff --git a/traitsui/qt4/tests/test_ui_base.py b/traitsui/qt/tests/test_ui_base.py similarity index 100% rename from traitsui/qt4/tests/test_ui_base.py rename to traitsui/qt/tests/test_ui_base.py diff --git a/traitsui/qt4/tests/test_ui_panel.py b/traitsui/qt/tests/test_ui_panel.py similarity index 97% rename from traitsui/qt4/tests/test_ui_panel.py rename to traitsui/qt/tests/test_ui_panel.py index 4344957c1..998680e30 100644 --- a/traitsui/qt4/tests/test_ui_panel.py +++ b/traitsui/qt/tests/test_ui_panel.py @@ -137,7 +137,7 @@ def default_traits_view(self): @requires_toolkit([ToolkitName.qt]) class TestUIPanel(unittest.TestCase): - def setup_qt4_dock_window(self): + def setup_qt_dock_window(self): from pyface.qt import QtGui # set up the dock window for qt @@ -148,10 +148,10 @@ def setup_qt4_dock_window(self): dock.setWidget(QtGui.QMainWindow()) return main_window, dock - def test_panel_has_toolbar_buttons_qt4(self): + def test_panel_has_toolbar_buttons_qt(self): from pyface.qt import QtGui - _, dock = self.setup_qt4_dock_window() + _, dock = self.setup_qt_dock_window() # add panel panel = FooPanel() @@ -166,10 +166,10 @@ def test_panel_has_toolbar_buttons_qt4(self): # popping up and closing the panel self.assertIsNotNone(ui.control.findChild(QtGui.QPushButton)) - def test_subpanel_has_toolbar_no_buttons_qt4(self): + def test_subpanel_has_toolbar_no_buttons_qt(self): from pyface.qt import QtGui - _, dock = self.setup_qt4_dock_window() + _, dock = self.setup_qt_dock_window() # add panel panel = FooPanel() diff --git a/traitsui/qt4/text_editor.py b/traitsui/qt/text_editor.py similarity index 100% rename from traitsui/qt4/text_editor.py rename to traitsui/qt/text_editor.py diff --git a/traitsui/qt4/time_editor.py b/traitsui/qt/time_editor.py similarity index 100% rename from traitsui/qt4/time_editor.py rename to traitsui/qt/time_editor.py diff --git a/traitsui/qt4/title_editor.py b/traitsui/qt/title_editor.py similarity index 100% rename from traitsui/qt4/title_editor.py rename to traitsui/qt/title_editor.py diff --git a/traitsui/qt4/toolkit.py b/traitsui/qt/toolkit.py similarity index 100% rename from traitsui/qt4/toolkit.py rename to traitsui/qt/toolkit.py diff --git a/traitsui/qt4/tree_editor.py b/traitsui/qt/tree_editor.py similarity index 100% rename from traitsui/qt4/tree_editor.py rename to traitsui/qt/tree_editor.py diff --git a/traitsui/qt4/tree_node_renderers.py b/traitsui/qt/tree_node_renderers.py similarity index 100% rename from traitsui/qt4/tree_node_renderers.py rename to traitsui/qt/tree_node_renderers.py diff --git a/traitsui/qt4/tuple_editor.py b/traitsui/qt/tuple_editor.py similarity index 100% rename from traitsui/qt4/tuple_editor.py rename to traitsui/qt/tuple_editor.py diff --git a/traitsui/qt4/ui_base.py b/traitsui/qt/ui_base.py similarity index 100% rename from traitsui/qt4/ui_base.py rename to traitsui/qt/ui_base.py diff --git a/traitsui/qt4/ui_editor.py b/traitsui/qt/ui_editor.py similarity index 100% rename from traitsui/qt4/ui_editor.py rename to traitsui/qt/ui_editor.py diff --git a/traitsui/qt4/ui_live.py b/traitsui/qt/ui_live.py similarity index 100% rename from traitsui/qt4/ui_live.py rename to traitsui/qt/ui_live.py diff --git a/traitsui/qt4/ui_modal.py b/traitsui/qt/ui_modal.py similarity index 100% rename from traitsui/qt4/ui_modal.py rename to traitsui/qt/ui_modal.py diff --git a/traitsui/qt4/ui_panel.py b/traitsui/qt/ui_panel.py similarity index 99% rename from traitsui/qt4/ui_panel.py rename to traitsui/qt/ui_panel.py index 6e746c3e4..1c7988e3d 100644 --- a/traitsui/qt4/ui_panel.py +++ b/traitsui/qt/ui_panel.py @@ -603,7 +603,7 @@ def __init__(self, group, ui, suppress_label=False): if group.visible_when != "" or group.enabled_when != "": # Make sure that outer is a widget and inner is a layout. # Hiding a layout is not properly supported by Qt (the - # workaround in ``traitsui.qt4.editor._visible_changed_helper`` + # workaround in ``traitsui.qt.editor._visible_changed_helper`` # often leaves undesirable blank space). if outer is None: outer = inner = QtGui.QBoxLayout(self.direction) diff --git a/traitsui/qt4/value_editor.py b/traitsui/qt/value_editor.py similarity index 100% rename from traitsui/qt4/value_editor.py rename to traitsui/qt/value_editor.py diff --git a/traitsui/qt4/video_editor.py b/traitsui/qt/video_editor.py similarity index 100% rename from traitsui/qt4/video_editor.py rename to traitsui/qt/video_editor.py diff --git a/traitsui/qt4/view_application.py b/traitsui/qt/view_application.py similarity index 100% rename from traitsui/qt4/view_application.py rename to traitsui/qt/view_application.py diff --git a/traitsui/qt4/__init__.py b/traitsui/qt4/__init__.py index 1cea02676..74a2daddc 100644 --- a/traitsui/qt4/__init__.py +++ b/traitsui/qt4/__init__.py @@ -1,4 +1,4 @@ -# (C) Copyright 2008-2023 Enthought, Inc., Austin, TX +# (C) Copyright 2005-2023 Enthought, Inc., Austin, TX # All rights reserved. # # This software is provided without warranty under the terms of the BSD @@ -8,31 +8,106 @@ # # Thanks for using Enthought open source! -# ------------------------------------------------------------------------------ -# Copyright (c) 2007, Riverbank Computing Limited -# All rights reserved. -# -# This software is provided without warranty under the terms of the BSD license. -# However, when used with the GPL version of PyQt the additional terms -# described in the PyQt GPL exception also apply +from importlib import import_module +from importlib.abc import MetaPathFinder, Loader +from importlib.machinery import ModuleSpec +try: + from importlib.metadata import version +except ImportError: + from importlib_metadata import version +from importlib.util import find_spec +import os +import sys +import warnings -# -# Author: Riverbank Computing Limited -# ------------------------------------------------------------------------------ +try: + from pyface.ui import ShadowedModuleFinder +except ImportError: + ShadowedModuleFinder = None +from traits.etsconfig.api import ETSConfig + + +if ShadowedModuleFinder is None: + # Either pyface is old, or we are in the future when ShadowedModuleFinder + # has been retired. Try to import pyface.ui.qt as a test; if it imports + # everything is good. + try: + import pyface.ui.qt # noqa: F401 + except ImportError: + raise RuntimeError( + """TraitsUI is running with an outdated version of Pyface + +The traitsui.qt4.* modules have moved to traitsui.qt.* and the older versions +of Pyface will not be aware of their new location. Update the version of +Pyface to at least 8.0.""", + DeprecationWarning, + stacklevel=2, + ) +elif any( + ( + isinstance(finder, ShadowedModuleFinder) + and finder.package == "traitsui.qt4." + ) + for finder in sys.meta_path +): + # Importing from traitsui.qt4.* is deprecated + # Already have loader registered. + warnings.warn( + """The traitsui.qt4.* modules have moved to traitsui.qt.* + +Backward compatibility import hooks are in place. They will be removed in a +future release of Pyface. +""", + DeprecationWarning, + stacklevel=2, + ) +elif ( + os.environ.get('ETS_QT4_IMPORTS', None) # environment says we want this + or os.environ.get('ETS_TOOLKIT', None) == "qt4" # environment says old qt4 + or ETSConfig.toolkit == "qt4" # the ETSConfig toolkit says old qt4 +): + # make sure that pyface.ui.qt4 loads before we do anything + import pyface.ui.qt4 + + # Register our loader. This is messing with global state that we do not own + # so we only do it when we have other global state telling us to. + + sys.meta_path.append(ShadowedModuleFinder( + package="traitsui.qt4.", + true_package="traitsui.qt.", + )) + + # Importing from traitsui.qt4.* is deprecated + warnings.warn( + """The traitsui.qt4.* modules have moved to traitsui.qt.* -""" Defines the concrete implementations of the traits Toolkit interface for -the PyQt user interface toolkit. -""" +Backward compatibility import hooks have been automatically applied. +They will be removed in a future release of Pyface. +""", + DeprecationWarning, + stacklevel=2, + ) +else: + # Don't import from this module, use a future warning as we want end-users + # of ETS apps to see the hints about environment variables. + warnings.warn( + """The traitsui.qt4.* modules have moved to traitsui.qt.*. -# import pyface.qt before anything else is done so the sipapi -# can be set correctly if needed -import pyface.qt +Applications which require backwards compatibility can either: -# ---------------------------------------------------------------------------- -# Define the reference to the exported GUIToolkit object: -# ---------------------------------------------------------------------------- +- set the ETS_QT4_IMPORTS environment variable +- set the ETS_TOOLKIT environment variable to "qt4", +- the ETSConfig.toolkit to "qt4" +- install a ShadowedModuleFinder into sys.meta_path:: -from . import toolkit + import sys + from pyface.ui import ShadowedModuleFinder -# Reference to the GUIToolkit object for Qt. -toolkit = toolkit.GUIToolkit("traitsui", "qt4", "traitsui.qt4") + sys.meta_path.append(ShadowedModuleFinder( + package="traitsui.qt4.", + true_package="traitsui.qt.", + )) +""", + FutureWarning, + stacklevel=2, + ) diff --git a/traitsui/testing/tester/_ui_tester_registry/default_registry.py b/traitsui/testing/tester/_ui_tester_registry/default_registry.py index d96994984..ddb7d2c16 100644 --- a/traitsui/testing/tester/_ui_tester_registry/default_registry.py +++ b/traitsui/testing/tester/_ui_tester_registry/default_registry.py @@ -34,7 +34,7 @@ def get_default_registries(): if ETSConfig.toolkit == "null": registries = [] else: - toolkit = {'wx': 'wx', 'qt4': 'qt4', 'qt': 'qt4'}[ETSConfig.toolkit] + toolkit = {'wx': 'wx', 'qt4': 'qt', 'qt': 'qt'}[ETSConfig.toolkit] this_package, _ = __name__.rsplit(".", 1) module = importlib.import_module( ".default_registry", this_package + '.' + toolkit diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/README.txt b/traitsui/testing/tester/_ui_tester_registry/qt/README.txt similarity index 100% rename from traitsui/testing/tester/_ui_tester_registry/qt4/README.txt rename to traitsui/testing/tester/_ui_tester_registry/qt/README.txt diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/__init__.py b/traitsui/testing/tester/_ui_tester_registry/qt/__init__.py similarity index 100% rename from traitsui/testing/tester/_ui_tester_registry/qt4/__init__.py rename to traitsui/testing/tester/_ui_tester_registry/qt/__init__.py diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_control_widget_registry.py b/traitsui/testing/tester/_ui_tester_registry/qt/_control_widget_registry.py similarity index 100% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_control_widget_registry.py rename to traitsui/testing/tester/_ui_tester_registry/qt/_control_widget_registry.py diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_interaction_helpers.py b/traitsui/testing/tester/_ui_tester_registry/qt/_interaction_helpers.py similarity index 99% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_interaction_helpers.py rename to traitsui/testing/tester/_ui_tester_registry/qt/_interaction_helpers.py index f56fcecef..6e15478d6 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/_interaction_helpers.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/_interaction_helpers.py @@ -16,7 +16,7 @@ check_key_compat, ) from traitsui.testing.tester.exceptions import Disabled -from traitsui.qt4.key_event_to_name import key_map as _KEY_MAP +from traitsui.qt.key_event_to_name import key_map as _KEY_MAP def key_click(widget, key, delay): diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_registry_helper.py b/traitsui/testing/tester/_ui_tester_registry/qt/_registry_helper.py similarity index 97% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_registry_helper.py rename to traitsui/testing/tester/_ui_tester_registry/qt/_registry_helper.py index d06297413..5b09fdf14 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/_registry_helper.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/_registry_helper.py @@ -18,7 +18,7 @@ MouseClick, ) from traitsui.testing.tester.query import DisplayedText -from traitsui.testing.tester._ui_tester_registry.qt4 import ( +from traitsui.testing.tester._ui_tester_registry.qt import ( _interaction_helpers, ) diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/README.txt b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/README.txt similarity index 100% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/README.txt rename to traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/README.txt diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/__init__.py b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/__init__.py similarity index 88% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/__init__.py rename to traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/__init__.py index 93087c904..cc720880d 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/__init__.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/__init__.py @@ -9,7 +9,7 @@ # Thanks for using Enthought open source! """ The organization in this package should more or less mirror that of -the ``traitsui.qt4`` package and contains the corresponding logic for testing. +the ``traitsui.qt`` package and contains the corresponding logic for testing. Note that once new implementations are added, they may need to be exposed via the ``default_registry`` module (one level up from this package). diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/boolean_editor.py b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/boolean_editor.py similarity index 91% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/boolean_editor.py rename to traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/boolean_editor.py index f78355e32..49e1f80f3 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/boolean_editor.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/boolean_editor.py @@ -10,10 +10,10 @@ from traitsui.testing.tester.command import MouseClick from traitsui.testing.tester.query import DisplayedText, IsChecked -from traitsui.testing.tester._ui_tester_registry.qt4 import ( +from traitsui.testing.tester._ui_tester_registry.qt import ( _interaction_helpers, ) -from traitsui.qt4.boolean_editor import ReadonlyEditor, SimpleEditor +from traitsui.qt.boolean_editor import ReadonlyEditor, SimpleEditor def register(registry): diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/button_editor.py b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/button_editor.py similarity index 91% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/button_editor.py rename to traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/button_editor.py index fb80327c4..c9780fed6 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/button_editor.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/button_editor.py @@ -10,10 +10,10 @@ from traitsui.testing.tester.command import MouseClick from traitsui.testing.tester.query import DisplayedText -from traitsui.testing.tester._ui_tester_registry.qt4 import ( +from traitsui.testing.tester._ui_tester_registry.qt import ( _interaction_helpers, ) -from traitsui.qt4.button_editor import CustomEditor, SimpleEditor +from traitsui.qt.button_editor import CustomEditor, SimpleEditor def register(registry): diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/check_list_editor.py b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/check_list_editor.py similarity index 95% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/check_list_editor.py rename to traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/check_list_editor.py index 66e6aab70..698e40792 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/check_list_editor.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/check_list_editor.py @@ -8,7 +8,7 @@ # # Thanks for using Enthought open source! -from traitsui.qt4.check_list_editor import CustomEditor +from traitsui.qt.check_list_editor import CustomEditor from traitsui.testing.tester.command import MouseClick from traitsui.testing.tester.locator import Index from traitsui.testing.tester._ui_tester_registry._common_ui_targets import ( @@ -17,7 +17,7 @@ from traitsui.testing.tester._ui_tester_registry._layout import ( column_major_to_row_major, ) -from traitsui.testing.tester._ui_tester_registry.qt4 import ( +from traitsui.testing.tester._ui_tester_registry.qt import ( _interaction_helpers, ) diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/directory_editor.py b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/directory_editor.py similarity index 86% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/directory_editor.py rename to traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/directory_editor.py index 14748ddcc..5fda898e4 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/directory_editor.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/directory_editor.py @@ -8,10 +8,10 @@ # # Thanks for using Enthought open source! -from traitsui.testing.tester._ui_tester_registry.qt4._registry_helper import ( +from traitsui.testing.tester._ui_tester_registry.qt._registry_helper import ( register_editable_textbox_handlers, ) -from traitsui.qt4.directory_editor import SimpleEditor +from traitsui.qt.directory_editor import SimpleEditor def register(registry): diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/editor_factory.py b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/editor_factory.py similarity index 88% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/editor_factory.py rename to traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/editor_factory.py index 7286a6ce5..c86155bc4 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/editor_factory.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/editor_factory.py @@ -9,10 +9,10 @@ # Thanks for using Enthought open source! from traitsui.testing.tester.query import DisplayedText -from traitsui.testing.tester._ui_tester_registry.qt4._registry_helper import ( +from traitsui.testing.tester._ui_tester_registry.qt._registry_helper import ( register_editable_textbox_handlers, ) -from traitsui.qt4.editor_factory import ReadonlyEditor, TextEditor +from traitsui.qt.editor_factory import ReadonlyEditor, TextEditor def register(registry): diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/enum_editor.py b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/enum_editor.py similarity index 98% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/enum_editor.py rename to traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/enum_editor.py index 11ff8a4c3..b331277f3 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/enum_editor.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/enum_editor.py @@ -8,7 +8,7 @@ # # Thanks for using Enthought open source! -from traitsui.qt4.enum_editor import ( +from traitsui.qt.enum_editor import ( ListEditor, RadioEditor, SimpleEditor, @@ -23,7 +23,7 @@ from traitsui.testing.tester._ui_tester_registry._common_ui_targets import ( BaseSourceWithLocation, ) -from traitsui.testing.tester._ui_tester_registry.qt4 import ( +from traitsui.testing.tester._ui_tester_registry.qt import ( _interaction_helpers, ) from traitsui.testing.tester._ui_tester_registry._layout import ( diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/file_editor.py b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/file_editor.py similarity index 87% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/file_editor.py rename to traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/file_editor.py index c8c83ae69..607e8b5a3 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/file_editor.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/file_editor.py @@ -8,10 +8,10 @@ # # Thanks for using Enthought open source! -from traitsui.testing.tester._ui_tester_registry.qt4._registry_helper import ( +from traitsui.testing.tester._ui_tester_registry.qt._registry_helper import ( register_editable_textbox_handlers, ) -from traitsui.qt4.file_editor import SimpleEditor +from traitsui.qt.file_editor import SimpleEditor def register(registry): diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/font_editor.py b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/font_editor.py similarity index 86% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/font_editor.py rename to traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/font_editor.py index 4d04d9384..6ad747b88 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/font_editor.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/font_editor.py @@ -8,10 +8,10 @@ # # Thanks for using Enthought open source! -from traitsui.testing.tester._ui_tester_registry.qt4._registry_helper import ( +from traitsui.testing.tester._ui_tester_registry.qt._registry_helper import ( register_editable_textbox_handlers, ) -from traitsui.qt4.font_editor import TextFontEditor +from traitsui.qt.font_editor import TextFontEditor def register(registry): diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/instance_editor.py b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/instance_editor.py similarity index 94% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/instance_editor.py rename to traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/instance_editor.py index 93968ba7c..c634870ea 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/instance_editor.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/instance_editor.py @@ -14,14 +14,14 @@ from traitsui.testing.tester._ui_tester_registry._common_ui_targets import ( BaseSourceWithLocation, ) -from traitsui.testing.tester._ui_tester_registry.qt4._interaction_helpers import ( # noqa +from traitsui.testing.tester._ui_tester_registry.qt._interaction_helpers import ( # noqa mouse_click_combobox, mouse_click_qwidget, ) from traitsui.testing.tester._ui_tester_registry._traitsui_ui import ( register_traitsui_ui_solvers, ) -from traitsui.qt4.instance_editor import CustomEditor, SimpleEditor +from traitsui.qt.instance_editor import CustomEditor, SimpleEditor def _get_nested_ui_simple(target): diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/list_editor.py b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/list_editor.py similarity index 96% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/list_editor.py rename to traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/list_editor.py index ff539c6f0..2377851e7 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/list_editor.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/list_editor.py @@ -16,10 +16,10 @@ from traitsui.testing.tester._ui_tester_registry._traitsui_ui import ( register_traitsui_ui_solvers, ) -from traitsui.testing.tester._ui_tester_registry.qt4 import ( +from traitsui.testing.tester._ui_tester_registry.qt import ( _interaction_helpers, ) -from traitsui.qt4.list_editor import CustomEditor, NotebookEditor, SimpleEditor +from traitsui.qt.list_editor import CustomEditor, NotebookEditor, SimpleEditor class _IndexedNotebookEditor(BaseSourceWithLocation): diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/range_editor.py b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/range_editor.py similarity index 97% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/range_editor.py rename to traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/range_editor.py index 18bc5fbea..4e6a495a5 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/range_editor.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/range_editor.py @@ -8,7 +8,7 @@ # # Thanks for using Enthought open source! -from traitsui.qt4.range_editor import ( +from traitsui.qt.range_editor import ( LargeRangeSliderEditor, LogRangeSliderEditor, RangeTextEditor, @@ -17,7 +17,7 @@ from traitsui.testing.tester.command import KeyClick from traitsui.testing.tester.locator import Slider, Textbox -from traitsui.testing.tester._ui_tester_registry.qt4 import ( +from traitsui.testing.tester._ui_tester_registry.qt import ( _interaction_helpers, _registry_helper, ) diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/table_editor.py b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/table_editor.py similarity index 97% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/table_editor.py rename to traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/table_editor.py index 0884e015c..c4189e559 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/table_editor.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/table_editor.py @@ -8,7 +8,7 @@ # # Thanks for using Enthought open source! -from traitsui.qt4.table_editor import SimpleEditor +from traitsui.qt.table_editor import SimpleEditor from traitsui.testing.tester.command import ( MouseClick, @@ -25,7 +25,7 @@ from traitsui.testing.tester._ui_tester_registry._common_ui_targets import ( BaseSourceWithLocation ) -from traitsui.testing.tester._ui_tester_registry.qt4 import ( +from traitsui.testing.tester._ui_tester_registry.qt import ( _interaction_helpers ) diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/text_editor.py b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/text_editor.py similarity index 85% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/text_editor.py rename to traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/text_editor.py index 01a3ae417..b76915aa1 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/text_editor.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/text_editor.py @@ -9,13 +9,13 @@ # Thanks for using Enthought open source! from traitsui.testing.tester.query import DisplayedText -from traitsui.testing.tester._ui_tester_registry.qt4 import ( +from traitsui.testing.tester._ui_tester_registry.qt import ( _interaction_helpers, ) -from traitsui.testing.tester._ui_tester_registry.qt4._registry_helper import ( +from traitsui.testing.tester._ui_tester_registry.qt._registry_helper import ( register_editable_textbox_handlers, ) -from traitsui.qt4.text_editor import CustomEditor, ReadonlyEditor, SimpleEditor +from traitsui.qt.text_editor import CustomEditor, ReadonlyEditor, SimpleEditor def register(registry): diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/ui_base.py b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/ui_base.py similarity index 92% rename from traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/ui_base.py rename to traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/ui_base.py index 8b7ccc99a..10120c5cc 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/_traitsui/ui_base.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/_traitsui/ui_base.py @@ -8,10 +8,10 @@ # # Thanks for using Enthought open source! -from traitsui.qt4.ui_base import ButtonEditor +from traitsui.qt.ui_base import ButtonEditor from traitsui.testing.tester.command import MouseClick from traitsui.testing.tester.query import DisplayedText -from traitsui.testing.tester._ui_tester_registry.qt4 import ( +from traitsui.testing.tester._ui_tester_registry.qt import ( _interaction_helpers, ) diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/default_registry.py b/traitsui/testing/tester/_ui_tester_registry/qt/default_registry.py similarity index 96% rename from traitsui/testing/tester/_ui_tester_registry/qt4/default_registry.py rename to traitsui/testing/tester/_ui_tester_registry/qt/default_registry.py index 6030a9002..262dd7f1d 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/default_registry.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/default_registry.py @@ -9,7 +9,7 @@ # Thanks for using Enthought open source! from traitsui.testing.tester.target_registry import TargetRegistry -from traitsui.testing.tester._ui_tester_registry.qt4._traitsui import ( +from traitsui.testing.tester._ui_tester_registry.qt._traitsui import ( boolean_editor, button_editor, check_list_editor, diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/tests/__init__.py b/traitsui/testing/tester/_ui_tester_registry/qt/tests/__init__.py similarity index 100% rename from traitsui/testing/tester/_ui_tester_registry/qt4/tests/__init__.py rename to traitsui/testing/tester/_ui_tester_registry/qt/tests/__init__.py diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/tests/test_control_widget_registry.py b/traitsui/testing/tester/_ui_tester_registry/qt/tests/test_control_widget_registry.py similarity index 96% rename from traitsui/testing/tester/_ui_tester_registry/qt4/tests/test_control_widget_registry.py rename to traitsui/testing/tester/_ui_tester_registry/qt/tests/test_control_widget_registry.py index 78c55521f..4fbdccb76 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/tests/test_control_widget_registry.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/tests/test_control_widget_registry.py @@ -29,7 +29,7 @@ if is_qt(): raise else: - from traitsui.testing.tester._ui_tester_registry.qt4._control_widget_registry import ( # noqa: E501 + from traitsui.testing.tester._ui_tester_registry.qt._control_widget_registry import ( # noqa: E501 get_widget_registry, ) diff --git a/traitsui/testing/tester/_ui_tester_registry/qt4/tests/test_interaction_helpers.py b/traitsui/testing/tester/_ui_tester_registry/qt/tests/test_interaction_helpers.py similarity index 99% rename from traitsui/testing/tester/_ui_tester_registry/qt4/tests/test_interaction_helpers.py rename to traitsui/testing/tester/_ui_tester_registry/qt/tests/test_interaction_helpers.py index 623e2ef8e..0acfa28dc 100644 --- a/traitsui/testing/tester/_ui_tester_registry/qt4/tests/test_interaction_helpers.py +++ b/traitsui/testing/tester/_ui_tester_registry/qt/tests/test_interaction_helpers.py @@ -18,7 +18,7 @@ ) from traitsui.testing.tester import command from traitsui.testing.tester.exceptions import Disabled -from traitsui.testing.tester._ui_tester_registry.qt4 import ( +from traitsui.testing.tester._ui_tester_registry.qt import ( _interaction_helpers, ) diff --git a/traitsui/tests/_tools.py b/traitsui/tests/_tools.py index fa3c90ff8..c504413de 100644 --- a/traitsui/tests/_tools.py +++ b/traitsui/tests/_tools.py @@ -152,7 +152,7 @@ def create_ui(object, ui_kwargs=None): return UITester().create_ui(object=object, ui_kwargs=ui_kwargs) -# ######### Utility tools to test on both qt4 and wx +# ######### Utility tools to test on both qt and wx def get_children(node): diff --git a/traitsui/tests/editors/test_date_editor.py b/traitsui/tests/editors/test_date_editor.py index 37f3ee208..2853aec53 100644 --- a/traitsui/tests/editors/test_date_editor.py +++ b/traitsui/tests/editors/test_date_editor.py @@ -74,7 +74,7 @@ def setUp(self): def tearDown(self): BaseTestMixin.tearDown(self) - def test_single_select_qt4(self): + def test_single_select_qt(self): with self.launch_editor(single_select_custom_view) as (foo, editor): date = datetime.date(2018, 2, 3) self.click_date_on_editor(editor, date) @@ -93,7 +93,7 @@ def test_multi_select_dates_on_editor(self): self.assertEqual(foo.dates, sorted(dates)) - def test_multi_select_qt4_styles_reset(self): + def test_multi_select_qt_styles_reset(self): with self.launch_editor(multi_select_custom_view) as (foo, editor): date = datetime.date(2018, 2, 1) self.click_date_on_editor(editor, date) @@ -102,7 +102,7 @@ def test_multi_select_qt4_styles_reset(self): self.click_date_on_editor(editor, date) self.check_select_status(editor=editor, date=date, selected=False) - def test_multi_select_qt4_set_model_dates(self): + def test_multi_select_qt_set_model_dates(self): # Test setting the dates from the model object. with self.launch_editor(multi_select_custom_view) as (foo, editor): foo.dates = [datetime.date(2010, 1, 2), datetime.date(2010, 2, 1)] diff --git a/traitsui/tests/editors/test_enum_editor.py b/traitsui/tests/editors/test_enum_editor.py index 045e20a93..54a90edb0 100644 --- a/traitsui/tests/editors/test_enum_editor.py +++ b/traitsui/tests/editors/test_enum_editor.py @@ -290,7 +290,7 @@ def test_simple_evaluate_editor_object_no_auto_set(self): self.assertEqual(enum_edit.value, "two") def test_simple_editor_resizable(self): - # Smoke test for `qt4.enum_editor.SimpleEditor.set_size_policy` + # Smoke test for `qt.enum_editor.SimpleEditor.set_size_policy` enum_edit = EnumModel() resizable_view = View(UItem("value", style="simple", resizable=True)) diff --git a/traitsui/tests/editors/test_html_editor.py b/traitsui/tests/editors/test_html_editor.py index b40500ed5..b2b931c55 100644 --- a/traitsui/tests/editors/test_html_editor.py +++ b/traitsui/tests/editors/test_html_editor.py @@ -202,7 +202,7 @@ def qt_target_registry(): ------- target_registry : TargetRegistry """ - from traitsui.qt4.html_editor import SimpleEditor + from traitsui.qt.html_editor import SimpleEditor registry = TargetRegistry() registry.register_interaction( diff --git a/traitsui/tests/editors/test_image_enum_editor.py b/traitsui/tests/editors/test_image_enum_editor.py index a101fbf18..8fab9c2fb 100644 --- a/traitsui/tests/editors/test_image_enum_editor.py +++ b/traitsui/tests/editors/test_image_enum_editor.py @@ -32,9 +32,9 @@ cache_to_patch = "traitsui.wx.image_enum_editor.bitmap_cache" elif is_qt(): - from traitsui.qt4.helper import pixmap_cache as image_cache + from traitsui.qt.helper import pixmap_cache as image_cache - cache_to_patch = "traitsui.qt4.image_enum_editor.pixmap_cache" + cache_to_patch = "traitsui.qt.image_enum_editor.pixmap_cache" is_linux = sys.platform == 'linux' diff --git a/traitsui/tests/editors/test_liststr_editor_selection.py b/traitsui/tests/editors/test_liststr_editor_selection.py index e8472824f..1aeb99330 100644 --- a/traitsui/tests/editors/test_liststr_editor_selection.py +++ b/traitsui/tests/editors/test_liststr_editor_selection.py @@ -744,10 +744,7 @@ def test_wx_list_str_multi_selected_index(self): def test_selection_listener_disconnected(self): """Check that selection listeners get correctly disconnected""" from pyface.qt.QtGui import QApplication, QItemSelectionModel - try: - from pyface.ui.qt.util.testing import event_loop - except ModuleNotFoundError: - from pyface.ui.qt4.util.testing import event_loop + from pyface.ui.qt.util.testing import event_loop obj = ListStrEditorWithSelectedIndex(values=["value1", "value2"]) diff --git a/traitsui/tests/editors/test_range_editor.py b/traitsui/tests/editors/test_range_editor.py index 04504f805..98b5e2d7e 100644 --- a/traitsui/tests/editors/test_range_editor.py +++ b/traitsui/tests/editors/test_range_editor.py @@ -53,10 +53,10 @@ def _register_simple_spin(registry): registry : TargetRegistry The registry being registered to. """ - from traitsui.testing.tester._ui_tester_registry.qt4 import ( + from traitsui.testing.tester._ui_tester_registry.qt import ( _registry_helper, ) - from traitsui.qt4.range_editor import SimpleSpinEditor + from traitsui.qt.range_editor import SimpleSpinEditor _registry_helper.register_editable_textbox_handlers( registry=registry, diff --git a/traitsui/tests/test_actions.py b/traitsui/tests/test_actions.py index 54462028d..d7ae78b41 100644 --- a/traitsui/tests/test_actions.py +++ b/traitsui/tests/test_actions.py @@ -105,7 +105,7 @@ def test_clicked(self): ) -# ----- qt4 helper functions +# ----- qt helper functions def _qt_trigger_action(container_class, ui): @@ -125,7 +125,7 @@ def _qt_click_button(ui): class TestActions(BaseTestMixin, unittest.TestCase): def _test_actions(self, trigger_action_func): - """Template test for wx, qt4, menu, and toolbar testing.""" + """Template test for wx, qt, menu, and toolbar testing.""" # Behavior: when clicking on a menu or toolbar action, # the corresponding function should be executed @@ -149,10 +149,7 @@ def test_qt_toolbar_action(self): # Bug: in the Qt4 backend, a # TypeError: perform() takes exactly 2 arguments (1 given) was raised # instead - try: - from pyface.ui.qt.action.tool_bar_manager import _ToolBar - except ModuleNotFoundError: - from pyface.ui.qt4.action.tool_bar_manager import _ToolBar + from pyface.ui.qt.action.tool_bar_manager import _ToolBar qt_trigger_toolbar_action = partial(_qt_trigger_action, _ToolBar) @@ -166,10 +163,7 @@ def test_qt_menu_action(self): # Bug: in the Qt4 backend, a # TypeError: perform() takes exactly 2 arguments (1 given) was raised # instead - try: - from pyface.ui.qt.action.menu_manager import _Menu - except ModuleNotFoundError: - from pyface.ui.qt4.action.menu_manager import _Menu + from pyface.ui.qt.action.menu_manager import _Menu qt_trigger_menu_action = partial( _qt_trigger_action, _Menu @@ -276,10 +270,7 @@ def test_qt_toolbar_action(self): # Bug: in the Qt4 backend, a # TypeError: perform() takes exactly 2 arguments (1 given) was raised # instead - try: - from pyface.ui.qt.action.tool_bar_manager import _ToolBar - except ModuleNotFoundError: - from pyface.ui.qt4.action.tool_bar_manager import _ToolBar + from pyface.ui.qt.action.tool_bar_manager import _ToolBar qt_trigger_toolbar_action = partial(_qt_trigger_action, _ToolBar) @@ -293,10 +284,7 @@ def test_qt_menu_action(self): # Bug: in the Qt4 backend, a # TypeError: perform() takes exactly 2 arguments (1 given) was raised # instead - try: - from pyface.ui.qt.action.menu_manager import _Menu - except ModuleNotFoundError: - from pyface.ui.qt4.action.menu_manager import _Menu + from pyface.ui.qt.action.menu_manager import _Menu qt_trigger_menu_action = partial(_qt_trigger_action, _Menu) diff --git a/traitsui/tests/test_ui.py b/traitsui/tests/test_ui.py index 20847b8f7..555762116 100644 --- a/traitsui/tests/test_ui.py +++ b/traitsui/tests/test_ui.py @@ -103,7 +103,7 @@ def test_reset_with_destroy_qt(self): # decorate children's `deleteLater` function to check that it is # called on `reset`. check only with the editor parts (only widgets # are scheduled. - # See traitsui.qt4.toolkit.GUIToolkit.destroy_children) + # See traitsui.qt.toolkit.GUIToolkit.destroy_children) for c in ui.control.children(): c.deleteLater = count_calls(c.deleteLater) @@ -159,7 +159,7 @@ def test_reset_without_destroy_qt(self): self.assertEqual(len(ui._editors), 2) self.assertIsInstance( - ui._editors[0], traitsui.qt4.text_editor.SimpleEditor + ui._editors[0], traitsui.qt.text_editor.SimpleEditor ) self.assertIsInstance(ui._editors[0].control, qt.QtGui.QLineEdit) @@ -167,7 +167,7 @@ def test_reset_without_destroy_qt(self): self.assertEqual(len(ui._editors), 2) self.assertIsInstance( - ui._editors[0], traitsui.qt4.text_editor.SimpleEditor + ui._editors[0], traitsui.qt.text_editor.SimpleEditor ) self.assertIsNone(ui._editors[0].control) diff --git a/traitsui/tests/test_view_application.py b/traitsui/tests/test_view_application.py index fd2a21689..eb6a774ab 100644 --- a/traitsui/tests/test_view_application.py +++ b/traitsui/tests/test_view_application.py @@ -102,10 +102,7 @@ def close_dialog(self): def click_button(self, text): if is_qt(): from pyface.qt.QtGui import QPushButton - try: - from pyface.ui.qt.util.testing import find_qt_widget - except ModuleNotFoundError: - from pyface.ui.qt4.util.testing import find_qt_widget + from pyface.ui.qt.util.testing import find_qt_widget button = find_qt_widget( self.handler.info.ui.control,