aqt.progress#
Classes#
Module Contents#
- class aqt.progress.ProgressManager(mw: aqt.AnkiQt)#
- mw#
- app#
- inDB = False#
- blockUpdates = False#
- timer(ms: int, func: collections.abc.Callable, repeat: bool, requiresCollection: bool = True, *, parent: QObject | None = None) QTimer#
Create and start a standard Anki timer. For an alternative see single_shot().
If the timer fires while a progress window is shown: - if it is a repeating timer, it will wait the same delay again - if it is non-repeating, it will try again in 100ms
If requiresCollection is True, the timer will not fire if the collection has been unloaded. Setting it to False will allow the timer to fire even when there is no collection, but will still only fire when there is no current progress dialog.
Issues and alternative — The created timer will only be destroyed when parent is destroyed. This can cause memory leaks, because anything captured by func isn’t freed either. If there is no QObject that will get destroyed reasonably soon, and you have to pass mw, you should call deleteLater() on the returned QTimer as soon as it’s served its purpose, or use single_shot().
Also note that you may not be able to pass an adequate parent, if you want to make a callback after a widget closes. If you passed that widget, the timer would get destroyed before it could fire.
- single_shot(ms: int, func: collections.abc.Callable[[], None], requires_collection: bool = True) None#
Create and start a one-off Anki timer. For an alternative and more documentation, see timer().
Issues and alternative — single_shot() cleans itself up, so a passed closure won’t leak any memory. However, if func references a QObject other than mw, which gets deleted before the timer fires, an Exception is raised. To avoid this, either use timer() passing that object as the parent, or check in func with sip.isdeleted(object) if it still exists.
On the other hand, if a widget is supposed to make an external callback after it closes, you likely want to use single_shot(), which will fire even if the calling widget is already destroyed.
- start(max: int = 0, min: int = 0, label: str | None = None, parent: QWidget | None = None, immediate: bool = False, title: str = 'Anki') ProgressDialog | None#
- start_with_backend_updates(progress_update: collections.abc.Callable[[anki.collection.Progress, ProgressUpdate], None], start_label: str | None = None, parent: QWidget | None = None) None#
- update(label: str | None = None, value: int | None = None, process: bool = True, maybeShow: bool = True, max: int | None = None) None#
- finish() None#
- clear() None#
Restore the interface after an error.
- busy() int#
True if processing.
- want_cancel() bool#
- set_title(title: str) None#