From c652bc97c2dd84db943641adcf1273e1bcb5f376 Mon Sep 17 00:00:00 2001 From: poka Date: Wed, 25 Nov 2020 08:10:22 +0100 Subject: [PATCH] Fix Annuler button; Add exceptions errors --- paiements.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/paiements.py b/paiements.py index 16802aa..b28729b 100755 --- a/paiements.py +++ b/paiements.py @@ -44,6 +44,11 @@ if not dunikey or not node: sys.exit(1) def ProceedPaiement(recipient, amount, comment): + if not recipient: + raise ValueError("Veuillez indiquer un destinataire de paiement") + elif not amount: + raise ValueError("Veuillez indiquer le montant de la transaction") + print("Paiement en cours vers", recipient) trans = Transaction(dunikey, node, recipient, amount, comment) trans.send() @@ -64,9 +69,10 @@ window = sg.Window('Paiement Ḡ1 - GVA', layout) while True: try: event, values = window.read() - if event == sg.WIN_CLOSED or event == 'Cancel': + if event == sg.WIN_CLOSED or event == 'Annuler': break - ProceedPaiement(values[0], values[1], values[2]) + if event == 'Envoyer': + ProceedPaiement(values[0], values[1], values[2]) except Exception as e: sg.popup(f'Une erreur est survenu', e, title="Erreur") else: