View Single Post
Old 05-06-2024, 10:21 PM   #2909
PeterT
Grand Sorcerer
PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.
 
PeterT's Avatar
 
Posts: 12,234
Karma: 74000000
Join Date: Nov 2007
Location: Toronto
Device: Nexus 7, Clara, Touch, Tolino EPOS
I think the standard approach has been to initially use a try / except block to initially attempt to import the new module name and if that fails import the old name.

See
Code:
try:
    from PyQt5.Qt import QUrl, pyqtSignal, QTimer
    from PyQt5.Qt import (QMenu, QModelIndex, QFileDialog, QIcon)
except ImportError:
    from PyQt4.Qt import QUrl, pyqtSignal, QTimer
    from PyQt4.Qt import (QMenu, QModelIndex, QFileDialog, QIcon)
as an example. (Code from the current Kobo Utilities plugin.)

Sent from my Pixel 7a using Tapatalk
PeterT is offline   Reply With Quote