Anki's Qt UI Module
The `aqt` package on PyPI, currently at version 25.9.2, serves as the internal Python module for the Anki flashcard application's graphical user interface. It is built upon the Qt toolkit, primarily through PyQt bindings, and is designed for the development of Anki add-ons and extensions. This package's release cadence is tied directly to the development and release cycle of the Anki application itself, which typically sees frequent updates.
Warnings
- gotcha This `aqt` package (version 25.9.2) is often confused with `aqtinstall`, a completely separate command-line utility for installing Qt binaries. They serve different purposes and are not interchangeable.
- gotcha The `aqt` package is primarily an internal module of the Anki application. Its API is not designed for standalone general-purpose GUI development and is subject to change with Anki updates without explicit deprecation cycles for external users.
- gotcha Installing `aqt` via pip does not provide a complete GUI framework for standalone applications. It relies on Anki's bundled Qt/PyQt environment. Attempting to use it outside an active Anki instance will likely result in missing dependencies or uninitialized components.
Install
-
pip install aqt
Imports
- mw
from aqt import mw
- editor
from aqt import editor
- browser
from aqt import browser
Quickstart
import aqt
from aqt.utils import showInfo
def my_anki_addon_action():
showInfo("Hello from my Anki add-on using aqt!")
# Example: Add a menu item to Anki's Tools menu
# This code is typically placed in an Anki add-on's __init__.py
# This requires Anki's main window (mw) to be available.
# In a real add-on, 'aqt.mw' is automatically populated.
# For a standalone runnable example, it would need a mock Anki environment.
# To simulate, if running directly, this part would not execute outside Anki
# if aqt.mw is None:
# print("Run this code within Anki for full functionality.")
# else:
# action = aqt.qt.QAction("My Custom Action", aqt.mw)
# action.triggered.connect(my_anki_addon_action)
# aqt.mw.form.menuTools.addAction(action)