From 6e52d752cc257bb8f3242e92ed2686a586606d49 Mon Sep 17 00:00:00 2001 From: Chengyu Liu Date: Thu, 30 Mar 2023 11:05:39 +0900 Subject: [PATCH 1/8] add kiwisolver not install warning for import error --- enable/api.py | 1 + 1 file changed, 1 insertion(+) diff --git a/enable/api.py b/enable/api.py index 400f0c9a6..591983fb3 100644 --- a/enable/api.py +++ b/enable/api.py @@ -283,6 +283,7 @@ try: import kiwisolver except ImportError: + print("kiwisolver not imported successfully imported. Please check it is installed.") pass else: from .constraints_container import ConstraintsContainer From ca630ee1420311fa92853c443775a6c2b12c2e5f Mon Sep 17 00:00:00 2001 From: Chengyu Liu Date: Thu, 30 Mar 2023 11:28:33 +0900 Subject: [PATCH 2/8] MAINT: add more kiwisolver import error --- enable/coordinate_box.py | 1 + enable/tests/test_constraints_container.py | 1 + 2 files changed, 2 insertions(+) diff --git a/enable/coordinate_box.py b/enable/coordinate_box.py index 7b9b95d6a..e5827ccca 100644 --- a/enable/coordinate_box.py +++ b/enable/coordinate_box.py @@ -16,6 +16,7 @@ try: import kiwisolver except ImportError: + print("kiwisolver not imported successfully imported. Please check it is installed.") ENABLE_CONSTRAINTS = False else: ENABLE_CONSTRAINTS = True diff --git a/enable/tests/test_constraints_container.py b/enable/tests/test_constraints_container.py index 76e32def6..4a89fd65d 100644 --- a/enable/tests/test_constraints_container.py +++ b/enable/tests/test_constraints_container.py @@ -15,6 +15,7 @@ import kiwisolver del kiwisolver except ImportError: + print("kiwisolver not imported successfully imported. Please check it is installed.") ENABLE_CONSTRAINTS = False else: ENABLE_CONSTRAINTS = True From cc18250dffa5cca620dd263adf0794205c6139a8 Mon Sep 17 00:00:00 2001 From: Chengyu Liu Date: Mon, 3 Apr 2023 11:26:31 +0900 Subject: [PATCH 3/8] add warning messages for kiwisolver --- enable/examples/demo/enable/constraints_demo.py | 5 +++++ enable/examples/demo/enable/image_draw.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/enable/examples/demo/enable/constraints_demo.py b/enable/examples/demo/enable/constraints_demo.py index 09a17eb29..379512ec1 100644 --- a/enable/examples/demo/enable/constraints_demo.py +++ b/enable/examples/demo/enable/constraints_demo.py @@ -8,6 +8,11 @@ # # Thanks for using Enthought open source! +# check kiwisolver installation +import importlib.util +if importlib.util.find_spec('kiwisolver') is None: + print("kiwisolver import not failed!!!! Please check it is installed.") + from enable.api import Component, ComponentEditor, ConstraintsContainer from enable.layout.api import ( align, grid, hbox, horizontal, spacer, vbox, vertical diff --git a/enable/examples/demo/enable/image_draw.py b/enable/examples/demo/enable/image_draw.py index 9f12a453e..001060cd5 100644 --- a/enable/examples/demo/enable/image_draw.py +++ b/enable/examples/demo/enable/image_draw.py @@ -12,6 +12,11 @@ """ import os +# check kiwisolver installation +import importlib.util +if importlib.util.find_spec('kiwisolver') is None: + print("kiwisolver import not failed!!!! Please check it is installed.") + from enable.api import ConstraintsContainer from enable.examples._example_support import DemoFrame, demo_main from enable.primitives.image import Image From 4b7b358894d89f8787709b21a9e9f01b3ce836b6 Mon Sep 17 00:00:00 2001 From: Chengyu Liu Date: Mon, 3 Apr 2023 13:42:24 +0900 Subject: [PATCH 4/8] fix QSvgWidget --- enable/savage/trait_defs/ui/qt4/svg_editor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/enable/savage/trait_defs/ui/qt4/svg_editor.py b/enable/savage/trait_defs/ui/qt4/svg_editor.py index f1b879bed..a90389831 100644 --- a/enable/savage/trait_defs/ui/qt4/svg_editor.py +++ b/enable/savage/trait_defs/ui/qt4/svg_editor.py @@ -17,12 +17,14 @@ from io import BytesIO from xml.etree.cElementTree import ElementTree +from PySide6.QtSvgWidgets import QSvgWidget from enable.savage.svg.document import SVGDocument from traitsui.qt4.editor import Editor -from pyface.qt import QtCore, QtSvg +from pyface.qt import QtCore + # ----------------------------------------------------------------------------- # 'SVGEditor' class: @@ -44,7 +46,7 @@ def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ - self.control = QtSvg.QSvgWidget() + self.control = QSvgWidget() # ------------------------------------------------------------------------- # Updates the editor when the object trait changes external to the editor: From ebd08df61960739d7152b79a5476a6e05fceb382 Mon Sep 17 00:00:00 2001 From: Chengyu Liu Date: Mon, 3 Apr 2023 17:03:34 +0900 Subject: [PATCH 5/8] remove warnings --- enable/api.py | 1 - enable/coordinate_box.py | 1 - enable/tests/test_constraints_container.py | 1 - 3 files changed, 3 deletions(-) diff --git a/enable/api.py b/enable/api.py index 591983fb3..400f0c9a6 100644 --- a/enable/api.py +++ b/enable/api.py @@ -283,7 +283,6 @@ try: import kiwisolver except ImportError: - print("kiwisolver not imported successfully imported. Please check it is installed.") pass else: from .constraints_container import ConstraintsContainer diff --git a/enable/coordinate_box.py b/enable/coordinate_box.py index e5827ccca..7b9b95d6a 100644 --- a/enable/coordinate_box.py +++ b/enable/coordinate_box.py @@ -16,7 +16,6 @@ try: import kiwisolver except ImportError: - print("kiwisolver not imported successfully imported. Please check it is installed.") ENABLE_CONSTRAINTS = False else: ENABLE_CONSTRAINTS = True diff --git a/enable/tests/test_constraints_container.py b/enable/tests/test_constraints_container.py index 4a89fd65d..76e32def6 100644 --- a/enable/tests/test_constraints_container.py +++ b/enable/tests/test_constraints_container.py @@ -15,7 +15,6 @@ import kiwisolver del kiwisolver except ImportError: - print("kiwisolver not imported successfully imported. Please check it is installed.") ENABLE_CONSTRAINTS = False else: ENABLE_CONSTRAINTS = True From 6b9b4f6b3bbaa7570cbe202064da885462f87006 Mon Sep 17 00:00:00 2001 From: Chengyu Liu Date: Mon, 3 Apr 2023 17:04:47 +0900 Subject: [PATCH 6/8] remove warnings --- enable/examples/demo/enable/constraints_demo.py | 5 ----- enable/examples/demo/enable/image_draw.py | 5 ----- 2 files changed, 10 deletions(-) diff --git a/enable/examples/demo/enable/constraints_demo.py b/enable/examples/demo/enable/constraints_demo.py index 379512ec1..09a17eb29 100644 --- a/enable/examples/demo/enable/constraints_demo.py +++ b/enable/examples/demo/enable/constraints_demo.py @@ -8,11 +8,6 @@ # # Thanks for using Enthought open source! -# check kiwisolver installation -import importlib.util -if importlib.util.find_spec('kiwisolver') is None: - print("kiwisolver import not failed!!!! Please check it is installed.") - from enable.api import Component, ComponentEditor, ConstraintsContainer from enable.layout.api import ( align, grid, hbox, horizontal, spacer, vbox, vertical diff --git a/enable/examples/demo/enable/image_draw.py b/enable/examples/demo/enable/image_draw.py index 001060cd5..9f12a453e 100644 --- a/enable/examples/demo/enable/image_draw.py +++ b/enable/examples/demo/enable/image_draw.py @@ -12,11 +12,6 @@ """ import os -# check kiwisolver installation -import importlib.util -if importlib.util.find_spec('kiwisolver') is None: - print("kiwisolver import not failed!!!! Please check it is installed.") - from enable.api import ConstraintsContainer from enable.examples._example_support import DemoFrame, demo_main from enable.primitives.image import Image From 9f41ae5a4e1e6201d58b639403ae4c21d3987383 Mon Sep 17 00:00:00 2001 From: Chengyu Liu Date: Tue, 4 Apr 2023 09:36:11 +0900 Subject: [PATCH 7/8] MAINT: check when import Q Widget --- enable/savage/trait_defs/ui/qt4/svg_editor.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/enable/savage/trait_defs/ui/qt4/svg_editor.py b/enable/savage/trait_defs/ui/qt4/svg_editor.py index a90389831..e8d8019de 100644 --- a/enable/savage/trait_defs/ui/qt4/svg_editor.py +++ b/enable/savage/trait_defs/ui/qt4/svg_editor.py @@ -17,7 +17,6 @@ from io import BytesIO from xml.etree.cElementTree import ElementTree -from PySide6.QtSvgWidgets import QSvgWidget from enable.savage.svg.document import SVGDocument @@ -25,6 +24,12 @@ from pyface.qt import QtCore +# import widget for different package cases +try: + from pyface.qt import QtSvg as QWidget +except: + from PySide6.QtSvgWidgets import QSvgWidget as QWidget + # ----------------------------------------------------------------------------- # 'SVGEditor' class: @@ -46,7 +51,7 @@ def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ - self.control = QSvgWidget() + self.control = QWidget() # ------------------------------------------------------------------------- # Updates the editor when the object trait changes external to the editor: From a0a9505a06e3ccf44961f93703b6bad9215118c4 Mon Sep 17 00:00:00 2001 From: Chengyu Liu Date: Tue, 4 Apr 2023 16:22:12 +0900 Subject: [PATCH 8/8] change QSvgWidget import --- enable/savage/trait_defs/ui/qt4/svg_editor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/enable/savage/trait_defs/ui/qt4/svg_editor.py b/enable/savage/trait_defs/ui/qt4/svg_editor.py index e8d8019de..c0d6c61be 100644 --- a/enable/savage/trait_defs/ui/qt4/svg_editor.py +++ b/enable/savage/trait_defs/ui/qt4/svg_editor.py @@ -26,9 +26,9 @@ # import widget for different package cases try: - from pyface.qt import QtSvg as QWidget + from pyface.qt.QtSvg import QSvgWidget except: - from PySide6.QtSvgWidgets import QSvgWidget as QWidget + from PySide6.QtSvgWidgets import QSvgWidget # ----------------------------------------------------------------------------- @@ -51,7 +51,7 @@ def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ - self.control = QWidget() + self.control = QSvgWidget() # ------------------------------------------------------------------------- # Updates the editor when the object trait changes external to the editor: