Hello everyone
I'm back with a new problem.
I wrote this template for the Single Field Edit module, the idea being to copy author names into a dialog box and format them before assigning them to the authors field.
Everything works perfectly, except that my dialog box opens twice, and also opens when I save the code. It works, so it's not too bad, but a bit annoying.
What should I do to solve the problem?
And once again, thank you so much for this incredible plugin, which has saved me a lot of time!
Code:
Code:
python:
def evaluate(book, context):
from PyQt5.QtWidgets import QInputDialog
sortie = ""
nom = ", ".join(book.authors)
source, ok = QInputDialog.getText(None, "Modification des auteurs", "Entrez les auteurs :")
if not ok:
return nom
source = source.replace(" (Auteur)", "").replace(" & ", ", ").replace(" et ", ", ").strip()
nom_transforme = []
for auteur in source.split(", "):
parts = auteur.split(" ", 1)
if len(parts) == 2:
prenom, nom_famille = parts
nom_transforme.append(f"{nom_famille.upper()}, {prenom.title()}")
else:
nom_transforme.append(auteur)
return " & ".join(nom_transforme)