mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Add a convenience function for creating toolbar links
Similar to aqt.editor.Editor.addButton
This commit is contained in:
parent
18ae9e612e
commit
621e634bb2
1 changed files with 10 additions and 1 deletions
|
@ -4,6 +4,8 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Dict
|
||||
|
||||
import aqt
|
||||
from anki.lang import _
|
||||
from aqt import gui_hooks
|
||||
|
@ -27,7 +29,7 @@ class Toolbar:
|
|||
def __init__(self, mw: aqt.AnkiQt, web: AnkiWebView) -> None:
|
||||
self.mw = mw
|
||||
self.web = web
|
||||
self.link_handlers = {
|
||||
self.link_handlers: Dict[str, Callable] = {
|
||||
"decks": self._deckLinkHandler,
|
||||
"study": self._studyLinkHandler,
|
||||
"add": self._addLinkHandler,
|
||||
|
@ -46,6 +48,13 @@ class Toolbar:
|
|||
# Available links
|
||||
######################################################################
|
||||
|
||||
def addLink(
|
||||
self, name: str, cmd: str, func: Callable, tip: str = "",
|
||||
):
|
||||
self.link_handlers[cmd] = func
|
||||
|
||||
return (cmd, name, tip)
|
||||
|
||||
def _centerLinks(self):
|
||||
links = [
|
||||
("decks", _("Decks"), _("Shortcut key: %s") % "D"),
|
||||
|
|
Loading…
Reference in a new issue