enthought / pyface

pyface: traits-capable windowing framework
Other
107 stars 55 forks source link

importing QSvgWidget from PySide6 no longer works #1235

Closed homosapien-lcy closed 1 year ago

homosapien-lcy commented 1 year ago

as mentioned by @mdickinson here https://github.com/enthought/enable/issues/1020, the pyface should provide a universal way to get QSvgWidget regardless of backend. I think the original import comes from here https://github.com/enthought/pyface/blob/main/pyface/qt/QtSvg.py

mdickinson commented 1 year ago

Key detail: for PySide6, it looks like QSvgWidget must be imported from the QtSvgWidgets top-level package instead of from QtSvg:

Enthought Deployment Manager -- https://www.enthought.com
Python 3.8.12 |Enthought, Inc. (x86_64)| (default, Sep 27 2021, 11:51:02) 
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PySide6.QtSvg  # package is still present
>>> from PySide6.QtSvg import QSvgWidget  # but doesn't contain QSvgWidget
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'QSvgWidget' from 'PySide6.QtSvg' (/Users/mdickinson/.edm/envs/canopy-data-ipython/lib/python3.8/site-packages/PySide6/QtSvg.cpython-38-darwin.so)
>>> from PySide6.QtSvgWidgets import QSvgWidget  # correct import location
>>> QSvgWidget
<class 'PySide6.QtSvgWidgets.QSvgWidget'>