I’m over 80, so I now rely on Anki as my major alternate hippopotamus (-campus ?)
I would be most grateful if someone could write an app to interchange the “Add” and “Close” buttons on the “Add” dialog (which is presented for adding/editing a card).
In the current configuration, I spend 98.37% of my Anki time reading the “Discard current input?” dialog.
I might not be alone:
"AI Overview
Learn more
Primary & Secondary Action Buttons | by Nick Babich | UX Planet
The desired action button in a dialog box should generally be placed on the right side. This is because it follows the natural reading pattern from left to right, and aligns with the user’s expectation of progressing forward."
from aqt.addcards import AddCards
from aqt.gui_hooks import add_cards_did_init
from aqt.qt import QHBoxLayout
def on_add_cards_did_init(addcards: AddCards) -> None:
bbox = addcards.form.buttonBox
for btn in bbox.buttons():
bbox.removeButton(btn)
addcards.form.verticalLayout_3.removeWidget(bbox)
hbox = QHBoxLayout()
hbox.addStretch()
# You can rearrange the buttons by changing the order of these lines.
hbox.addWidget(addcards.historyButton)
hbox.addWidget(addcards.helpButton)
hbox.addWidget(addcards.closeButton)
hbox.addWidget(addcards.addButton)
addcards.form.verticalLayout_3.addLayout(hbox)
add_cards_did_init.append(on_add_cards_did_init)
When loading Switch_Add_Close_buttons:
Traceback (most recent call last):
File “aqt.addons”, line 250, in loadAddons
File “C:\Users<me>\AppData\Roaming\Anki2\addons21\Switch_Add_Close_buttons_init_.py”, line 1, in init.py
NameError: name ‘init’ is not defined
__init__.py refers to the filename, not part of the code itself. The actual first line of the add-on code is: from aqt.addcards import AddCards
Please make sure to name the file __init__.py, as this is required. For more details about the folder structure specifications for add-ons, please refer to this link.
I took the liberty to put it in the proper anki addon format. simply download and execute this file and it will install the code of hkr. All credits to him, I haven’t tested it or changed anything.
Feel free to edit the source code afterwards in your addons folder (you can find the source in addons21/button_switcher/__init__.py