The add-on author author could take a look at Porting tips for Anki 23.10 - Add-ons - Anki Forums
Modules under QtCore, QtGui and QtWidgets can be imported from aqt.qt instead, to remove old PyQt5 dependencies.
The add-on author author could take a look at Porting tips for Anki 23.10 - Add-ons - Anki Forums
Modules under QtCore, QtGui and QtWidgets can be imported from aqt.qt instead, to remove old PyQt5 dependencies.
Hey
I tried installing the asset manager add-on but Anki seems to be unable to install or “use” the package.
I just keep getting a error message and having to delete the add on.
Anki 24.04.1 (ccd9ca1a)
Thanks for helping
[asset manager][Anki 25.09.2] works, then crashes later?
PyQt5→PyQt6,
from aqt.qt import (QRegExp→from aqt.qt import (QRegularExpression as QRegExp,
QtCore.Qt.WindowModal→QtCore.Qt.WindowModality.WindowModal,
QtWidgets.QSizePolicy.Fixed→QtWidgets.QSizePolicy.Policy.Fixed,
QtCore.Qt.Horizontal→QtCore.Qt.Orientation.Horizontal
QtWidgets.QDialogButtonBox.Ok→QtWidgets.QDialogButtonBox.StandardButton.Ok,
QtWidgets.QDialogButtonBox.Cancel→QtWidgets.QDialogButtonBox.StandardButton.Cancel,
QtWidgets.QFrame.HLine→QtWidgets.QFrame.Shape.HLine,
QtWidgets.QFrame.Sunken→QtWidgets.QFrame.Shadow.Sunken,
QLayout.SetFixedSize→QLayout.SizeConstraint.SetFixedSize,
exec_()→exec(),
QtWidgets.QSizePolicy.Expanding→QtWidgets.QSizePolicy.Policy.Expanding,
QtWidgets.QSizePolicy.Minimum→QtWidgets.QSizePolicy.Policy.Minimum,
QtWidgets.QAbstractItemView.NoEditTriggers→QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers,
QtWidgets.QAbstractItemView.SingleSelection→QtWidgets.QAbstractItemView.SelectionMode.SingleSelection,
QtWidgets.QAbstractItemView.SelectRows→QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows,
#self.scriptsTable.setGridStyle(QtCore.Qt.DashLine),
Qt.AlignCenter→Qt.AlignmentFlag.AlignCenter,
QFont.Monospace→QFont.StyleHint.Monospace,
QFont.Medium→QFont.Weight.Medium,
QFont.Bold→QFont.Weight.Bold,
Qt.GlobalColor.cyan blue magenta darkMagenta red darkRed yellow darkYellow green darkGreen lightGray gray,
reducer=lambda lst: "\n\n".join(lst),→reducer=lambda lst: "\n\n".join(x[0] if isinstance(x, tuple) else str(x) for x in lst), #chatgpt
def highlightBlock(self, text): #chatgpt
# --- Handle normal syntax rules ---
for pattern, format in self.highlightingRules:
expression = QRegularExpression(pattern)
match_iterator = expression.globalMatch(text)
while match_iterator.hasNext():
match = match_iterator.next()
index = match.capturedStart()
length = match.capturedLength()
self.setFormat(index, length, format)
self.setCurrentBlockState(0)
# --- Handle multi-line comments ---
startIndex = 0
if self.previousBlockState() != 1:
start_match = self.commentStartExpression.match(text)
startIndex = start_match.capturedStart() if start_match.hasMatch() else -1
while startIndex >= 0:
end_match = self.commentEndExpression.match(text, startIndex)
if end_match.hasMatch():
endIndex = end_match.capturedStart()
commentLength = endIndex - startIndex + end_match.capturedLength()
self.setCurrentBlockState(0)
else:
self.setCurrentBlockState(1)
commentLength = len(text) - startIndex
self.setFormat(startIndex, commentLength, self.multiLineCommentFormat)
# Look for next comment start
next_match = self.commentStartExpression.match(text, startIndex + commentLength)
startIndex = next_match.capturedStart() if next_match.hasMatch() else -1
Replaced all entries - now, just nothing happens. All that’s working is “Asset Manager Settings” window. The rest is nowhere to be found.
So, there is also “Assetts…” button in Tools→’Manage Note Types’ menu, which isn’t described anywhere in the addon docs smh.
To make everything work you need to replace the following in every file in addon’s code (where it presented):
self.scriptsTable.setGridStyle(QtCore.Qt.PenStyle.DashLine) → self.scriptsTable.setGridStyle(QtCore.Qt.DashLine) QSizePolicy.Preferred → QSizePolicy.Policy.PreferredQt to Qt.GlobalColor in all of these. For example: Qt.manentato Qt.GlobalColor.magenta, Qt.red to Qt.GlobalColor.red.QColor(). For example Qt.GlobalColor.cyan if is_night_mode else Qt.GlobalColor.blue to QColor(Qt.GlobalColor.cyan if is_night_mode else Qt.GlobalColor.blue)from aqt import QDialog, QLayout, QKeySequence → from aqt.qt import QDialog, QLayout, QKeySequenceNext, I’ll take the post with the code above, which it is strangely formatted, and translate it to you:
self.scriptsTable). Substitutions are pairs of the source and target strings, divided by “→”.PyQt5 → PyQt6Qt.GlobalColor.cyan, since we already did corresponding substitution in step 3.highlightBlock which text goes to the end of the post.highlightBlock function is located in highliighter.py.