I tried few solutions with ChatGPT, however it doesn’t work.
What add-on I would like to have? Right after choosing “Add” i would like to have some string in the first field, added there automatically. Also, during editing any note, if the first fild is empty, I want to put there that string. How to do that? What approche to have?
Hi Danika, I didn’t try, however thank you for telling me that, because I was not aware of this functionality. In my first post I forgot to write that I would need every time different string returned by my function.
I the meanwhile a preliminary solution has been found. Here it is:
from aqt import editor, gui_hooks
import random
def update_field(editor):
#print('Hello world!')
note = editor.note
note_type = editor.note.note_type()
if 'field_name' not in note:
print('Field not found')
return
if note['field_name']:
print(f'Field is not empty')
return
value_to_set = random.randint(0, 100)
note['field_name'] = f'{value_to_set}'
editor.loadNote()
gui_hooks.editor_did_load_note.append(update_field)