Anki's Qt UI Module

25.9.2 · active · verified Sun Apr 12

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

Install

Imports

Quickstart

This quickstart demonstrates how to interact with Anki's main window and show a simple info dialog using the `aqt` module, as typically done within an Anki add-on. This code is intended to be run within the Anki application environment, where `aqt.mw` and `aqt.qt` (PyQt bindings) are already initialized.

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)

view raw JSON →