Hey there!
I am currently working on an add-on. It is mainly a text-editor and I want to implement the function to automatically clear the text editor (delete all the text that is in the text editor) after the user reviewed a card and a specific checkbox is checked.
My code for this function:
check = QCheckBox("Auto Clear")
check.stateChanged.connect(lambda: toggle_auto_clear(check))
button_layout.addWidget(check)
def toggle_auto_clear(checkbox):
if not checkbox.isChecked():
checkbox.setText("Auto Clear OFF")
else:
checkbox.setText("Auto Clear ON")
auto_clear_func()
def auto_clear_func(reviewer: Reviewer, card: Card, ease: Literal[1, 2, 3, 4]) -> None:
global text_editor, numeric_list_active
text_editor.clear()
numeric_list_active = False
text_editor.setFocus()
gui_hooks.reviewer_did_answer_card.append(auto_clear_func)
But if I check the checkbox I encounter the following error:
Debuginformationen:
Anki 2.1.65 (aa9a734f) Python 3.9.15 Qt 6.4.3 PyQt 6.4.0
Platform: Windows-10-10.0.19045
Flags: frz=True ao=True sv=3
Add-ons, last update check: 2023-10-05 10:07:43Caught exception:
Traceback (most recent call last):
File “C:\Users\Joystick6123\AppData\Roaming\Anki2\addons21\Tab Note 2_init_.py”, line 67, in
check.stateChanged.connect(lambda: toggle_auto_clear(check))
File “C:\Users\Joystick6123\AppData\Roaming\Anki2\addons21\Tab Note 2_init_.py”, line 94, in toggle_auto_clear
auto_clear_func()
TypeError: auto_clear_func() missing 3 required positional arguments: ‘reviewer’, ‘card’, and ‘ease’
I would appreciate any help. Thank you in advance!