mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Allow add-ons to register custom dialogs with the dialog manager
This commit is contained in:
parent
0f9683a850
commit
1ed2ba8983
1 changed files with 18 additions and 1 deletions
|
@ -10,7 +10,7 @@ import os
|
|||
import sys
|
||||
import tempfile
|
||||
import traceback
|
||||
from typing import Any, Dict, Optional
|
||||
from typing import Any, Callable, Dict, Optional, Union
|
||||
|
||||
import anki.buildinfo
|
||||
import anki.lang
|
||||
|
@ -126,6 +126,23 @@ class DialogManager:
|
|||
|
||||
return True
|
||||
|
||||
def register_dialog(
|
||||
self, name: str, creator: Union[Callable, type], instance: Optional[Any] = None
|
||||
):
|
||||
"""Allows add-ons to register a custom dialog to be managed by Anki's dialog
|
||||
manager
|
||||
|
||||
Arguments:
|
||||
name {str} -- Name/identifier of the dialog in question
|
||||
creator {Union[Callable, type]} -- A class or function to create new
|
||||
dialog instances with
|
||||
|
||||
Keyword Arguments:
|
||||
instance {Optional[Any]} -- An optional existing instance of the dialog
|
||||
(default: {None})
|
||||
"""
|
||||
self._dialogs[name] = [creator, instance]
|
||||
|
||||
|
||||
dialogs = DialogManager()
|
||||
|
||||
|
|
Loading…
Reference in a new issue