1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| def debut_av(): ### paramétrage début
la = 10
lo = 10
cartex = init_carte(la, lo)
affiche_carte('', la, lo, cartex, [])
nomvv = fenetrenom() ### ouvre une fenêtre demandant nom & vérifiant
mission(nomvv, 0, la, lo, carte) ### lance la mission
def fenetrenom(): ### ouvre une fenêtre demandant le nom
def onclose(): ### récupère nom & ferme 'fennom' si le nom est valide
nomvv = aa.get() # Lecture de l'Entry
bo = verif_nom(value)
if bo == '':
fennom.destroy() # La destruction du Toplevel n'arrete pas la fonction
return nomvv # The end ;)
else :
txbo.config(text=bo) ### modifie le texte de la première ligne de 'fennom' selon l'erreur commise
txbo.update() # A la limite, mais pas un .pack()
# txbo.pack(padx=5,pady=5)
fennom = Tk.Toplevel(master=racine)
fennom.transient(master=racine)
fennom.wm_geometry('%dx%d+%d+%d'% (600, 270, 400, 260))
fennom.title('Nom du Village Vacances')
fennom.config(bg='dark grey')
# while nomvv == '' : Vous rendez vous compte que vous créer des widgets et écrasez le 'nom' (pas les widgets) de ceux existants dans une boucle ?
txbo = Tk.Label(fennom, text='Nom du VV ?\n(de 3 à 16 lettres)', fg='black', bd=16, bg='dark grey', font=beb16)
txbo.pack(padx=5, pady=5)
# Pour tester garder votre code et mettez un print(txbo) ici. Vous comprendrez.
aa = Tk.Entry(fennom, width=16, font='Arial 16') # Le seul truc qui vous sauve dans votre while c'est textvariable car l'instance nom (la classe StringVar) est unique.
aa.pack(padx=5, pady=5)
Tk.Label(fennom, text='\n', bg='dark grey').pack(padx=5, pady=5)
Tk.Button(fennom, command=onclose, text='Valider', bd=16, bg='yellow', font=beb16).pack(padx=5, pady=5)
fennom.protocol('WM_DELETE_WINDOW', onclose) # Optionnel. Permet de forcer une saisie par rapport à onclose
# racine.mainloop() ? Toujours pas compris la présence du mainloop ici. |