aqt.main#
Attributes#
Classes#
Create a collection of name/value pairs. |
Module Contents#
- aqt.main.MainWindowState#
- aqt.main.T#
- class aqt.main.MainWebView(mw: AnkiQt)#
Bases:
aqt.webview.AnkiWebView- mw#
- dragEnterEvent(event: QDragEnterEvent) None#
- dropEvent(event: QDropEvent) None#
- eventFilter(obj: QObject | None, evt: QEvent | None) bool#
- class aqt.main.AnkiQt(app: aqt.AnkiApp, profileManager: aqt.profiles.ProfileManager, backend: anki._backend.RustBackend, opts: argparse.Namespace, args: list[Any])#
Bases:
QMainWindow- web: MainWebView#
- bottomWeb: aqt.toolbar.BottomWebView#
- backend#
- state: MainWindowState = 'startup'#
- opts#
- taskman#
- media_syncer#
- app#
- fullscreen = False#
- safeMode#
- setupUI() None#
- finish_ui_setup() None#
Actions that are deferred until after add-on loading.
- setupProfileAfterWebviewsLoaded() None#
- setup_focus() None#
- on_focus_changed(old: QWidget, new: QWidget) None#
- class ProfileManager#
Bases:
QMainWindow- onClose#
- closeFires = True#
- closeEvent(evt: QCloseEvent) None#
- closeWithoutQuitting() None#
- setupProfile() None#
- showProfileManager() None#
- refreshProfilesList() None#
- onProfileRowChange(n: int) None#
- openProfile() None#
- onOpenProfile(*, callback: collections.abc.Callable[[], None] | None = None) None#
- profileNameOk(name: str) bool#
- onAddProfile() None#
- onRenameProfile() None#
- onRemProfile() None#
- onOpenBackup() None#
- loadProfile(onsuccess: collections.abc.Callable | None = None) None#
- unloadProfile(onsuccess: collections.abc.Callable) None#
- unloadProfileAndExit() None#
- unloadProfileAndShowProfileManager() None#
- cleanupAndExit() None#
- setup_sound() None#
- cleanup_sound() None#
- prepare_card_text_for_display(text: str) str#
- loadCollection() bool#
- reopen(after_full_sync: bool = False) None#
- unloadCollection(onsuccess: collections.abc.Callable) None#
- apply_collection_options() None#
Setup audio after collection loaded.
- maybeOptimize() None#
- moveToState(state: MainWindowState, *args: Any) None#
- on_operation_did_execute(changes: anki.collection.OpChanges, handler: object | None) None#
Notify current screen of changes.
- on_focus_did_change(new_focus: QWidget | None, _old: QWidget | None) None#
If main window has received focus, ensure current UI state is updated.
- fade_out_webview() None#
- fade_in_webview() None#
- reset(unused_arg: bool = False) None#
Legacy method of telling UI to refresh after changes made to DB.
New code should use CollectionOp() instead.
- requireReset(modal: bool = False, reason: Any | None = None, context: Any | None = None) None#
- maybeReset() None#
- delayedMaybeReset() None#
- button(link: str, name: str, key: str | None = None, class_: str = '', id: str = '', extra: str = '') str#
- setupMainWindow() None#
- closeAllWindows(onsuccess: collections.abc.Callable) None#
- setupSignals() None#
- onUnixSignal(signum: Any, frame: Any) None#
- setupProgress() None#
- setupErrorHandler() None#
- setupAddons(args: list | None) None#
- maybe_check_for_addon_updates(on_done: collections.abc.Callable[[list[aqt.addons.DownloadLogEntry]], None] | None = None) None#
- check_for_addon_updates(by_user: bool, on_done: collections.abc.Callable[[list[aqt.addons.DownloadLogEntry]], None] | None = None) None#
- on_updates_installed(log: list[aqt.addons.DownloadLogEntry]) None#
- setupSpellCheck() None#
- setupThreads() None#
- inMainThread() bool#
- setupDeckBrowser() None#
- setupOverview() None#
- setupReviewer() None#
- on_sync_button_clicked() None#
- maybe_auto_sync_on_open_close(after_sync: collections.abc.Callable[[bool], None]) None#
If disabled, after_sync() is called immediately.
- can_auto_sync() bool#
True if syncing on startup/shutdown enabled.
- onSync#
- raiseMain() bool#
- setupStyle() None#
- set_theme(theme: aqt.theme.Theme) None#
- setupKeys() None#
- applyShortcuts(shortcuts: collections.abc.Sequence[tuple[str, collections.abc.Callable]]) list[QShortcut]#
- setStateShortcuts(shortcuts: list[tuple[str, collections.abc.Callable]]) None#
- clearStateShortcuts() None#
- onStudyKey() None#
- closeEvent(event: QCloseEvent) None#
- undo() None#
Call operations/collection.py:undo() directly instead.
- redo() None#
Call operations/collection.py:redo() directly instead.
- undo_actions_info() aqt.undo.UndoActionsInfo#
Info about the current undo/redo state for updating menus.
- update_undo_actions() None#
Tell the UI to redraw the undo/redo menu actions based on the current state.
Usually you do not need to call this directly; it is called when a CollectionOp is run, and will be called when the legacy .reset() or .checkpoint() methods are used.
- checkpoint(name: str) None#
- autosave() None#
- onUndo#
- onAddCard() None#
- onBrowse() None#
- onEditCurrent() None#
- onOverview() None#
- onStats() None#
- onPrefs() None#
- on_upgrade_downgrade() None#
- onNoteTypes() None#
- onAbout() None#
- onDonate() None#
- onDocumentation() None#
- onDeckConf(deck: anki.decks.DeckDict | None = None) None#
- handleImport(path: str) None#
Importing triggered via file double-click, or dragging file onto Anki icon.
- onImport() None#
Importing triggered via File>Import.
- onExport(did: anki.decks.DeckId | None = None) None#
- installAddon(path: str, startup: bool = False) None#
- onCram() None#
- setupMenus() None#
- updateTitleBar() None#
- on_toggle_full_screen() None#
- setup_auto_update(_log: list[aqt.addons.DownloadLogEntry]) None#
- setup_timers() None#
- onRefreshTimer() None#
- on_periodic_sync_timer() None#
- on_periodic_backup_timer() None#
Create a backup if enough time has elapsed and collection changed.
- on_create_backup_now() None#
- create_backup_now() None#
Create a backup immediately, regardless of when the last one was created. Waits until the backup completes. Intended to be used as part of a longer-running CollectionOp/QueryOp.
- setupHooks() None#
- onOdueInvalid() None#
- on_av_player_will_play(tag: anki.sound.AVTag) None#
Record active window to restore after video playing.
- on_av_player_did_end_playing(player: Any) None#
Restore window focus after a video was played.
- onRemNotes(col: anki.collection.Collection, nids: collections.abc.Sequence[anki.notes.NoteId]) None#
- onSchemaMod(arg: bool) bool#
- confirm_schema_modification() bool#
If schema unmodified, ask user to confirm change. True if confirmed or already modified.
- onCheckDB() None#
- on_check_media_db() None#
- onStudyDeck() None#
- onEmptyCards() None#
- setupSystemSpecific() None#
- maybeHideAccelerators(tgt: Any | None = None) None#
- hideStatusTips() None#
- onMacMinimize() None#
- setupAppMsg() None#
- onAppMsg(buf: str) None#
- interactiveState() bool#
True if not in profile manager, syncing, etc.
- garbage_collect_on_dialog_finish(dialog: QDialog) None#
- deferred_delete_and_garbage_collect(obj: QObject) None#
- disable_automatic_garbage_collection() None#
- garbage_collect_now() None#
- setupDialogGC#
- gcWindow#
- setupMediaServer() None#
- baseHTML() str#
- serverURL() str#
- class aqt.main.ResetReason(*args, **kwds)#
Bases:
enum.EnumCreate a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- Unknown = 'unknown'#
- AddCardsAddNote = 'addCardsAddNote'#
- EditCurrentInit = 'editCurrentInit'#
- EditorBridgeCmd = 'editorBridgeCmd'#
- BrowserSetDeck = 'browserSetDeck'#
- BrowserAddTags = 'browserAddTags'#
- BrowserRemoveTags = 'browserRemoveTags'#
- BrowserSuspend = 'browserSuspend'#
- BrowserReposition = 'browserReposition'#
- BrowserReschedule = 'browserReschedule'#
- BrowserFindReplace = 'browserFindReplace'#
- BrowserTagDupes = 'browserTagDupes'#
- BrowserDeleteDeck = 'browserDeleteDeck'#