mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Extend showInfo with the ability to add custom buttons
Grants more flexibility in user prompt design
This commit is contained in:
parent
ce1853167b
commit
00991e8e8e
1 changed files with 19 additions and 3 deletions
|
@ -50,7 +50,15 @@ def showCritical(text, parent=None, help="", title="Anki", textFormat=None):
|
|||
return showInfo(text, parent, help, "critical", title=title, textFormat=textFormat)
|
||||
|
||||
|
||||
def showInfo(text, parent=False, help="", type="info", title="Anki", textFormat=None):
|
||||
def showInfo(
|
||||
text,
|
||||
parent=False,
|
||||
help="",
|
||||
type="info",
|
||||
title="Anki",
|
||||
textFormat=None,
|
||||
customBtns=None
|
||||
):
|
||||
"Show a small info window with an OK button."
|
||||
if parent is False:
|
||||
parent = aqt.mw.app.activeWindow() or aqt.mw
|
||||
|
@ -70,6 +78,14 @@ def showInfo(text, parent=False, help="", type="info", title="Anki", textFormat=
|
|||
mb.setText(text)
|
||||
mb.setIcon(icon)
|
||||
mb.setWindowTitle(title)
|
||||
if customBtns:
|
||||
default = None
|
||||
for btn in customBtns:
|
||||
b = mb.addButton(btn)
|
||||
if not default:
|
||||
default = b
|
||||
mb.setDefaultButton(default)
|
||||
else:
|
||||
b = mb.addButton(QMessageBox.Ok)
|
||||
b.setDefault(True)
|
||||
if help:
|
||||
|
|
Loading…
Reference in a new issue