bonjour,
j'ai un petit script qui contrôle le choix dans combobox cad il ne quitte le combo que si le choix est différent du "-----CHOIX-----" index 0 sinon un message d'erreur s’affiche
le problème que j'ai c'est que quand j'appuis sur la flèche du combo j'ai le message or je souhaite que le message ne s’affiche que si je quitter le combo sans faire un choix




Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
37
38
39
40
41
from tkinter import *
from tkinter.messagebox import *
from tkinter import ttk
 
 
fenetre_Creation_Proprietaire = Tk()
fenetre_Creation_Proprietaire.title('CREATION PROPRIETAIRE')
fenetre_Creation_Proprietaire.geometry("1150x450")
 
 
def Quitter_Focus(StringT):
    Valeur=StringT.get()
    Longueur=len(Valeur)
    if 'CHOIX' in Valeur :
            showerror('Erreur: Saisie De Champ ', "Choix Du Mois Obligatoire")
            ChoixMois.focus_set()
 
 
 
Label(fenetre_Creation_Proprietaire, bg='red',text="Mois") .place(x=110,y=20, height=25, width=50)
 
ListeChoix=['-----CHOIX-----','JANVIER', 'FEVRIER','MARS','AVRIL']
Choix_Mois = StringVar()
ChoixMois = ttk.Combobox(fenetre_Creation_Proprietaire, state = 'readonly',values=ListeChoix,name="choixmois",textvariable = Choix_Mois)
ChoixMois.place(x=165,y=20,height=25, width=115)
ChoixMois.current(0)
ChoixMois.focus_set()
ChoixMois.bind('<FocusOut>', lambda e, : Quitter_Focus(Choix_Mois))
 
 
LabNomPre=Label(fenetre_Creation_Proprietaire, bg='red',text="Nom & Prénom")
LabNomPre.place(x=490,y=20, height=25, width=100)
Nom_Pre=StringVar()
NomPre=Entry(fenetre_Creation_Proprietaire, font=("Purisa", 13), bg="yellow",  justify="left",textvariable=Nom_Pre)
NomPre.place(x=595,y=20, height=25, width=300)
NomPre.bind('<Return>', lambda event: NumCin.focus_set())
Nom_Pre.trace("w", lambda *a:Nom_Pre.set(Nom_Pre.get().upper()))
 
 
 
fenetre_Creation_Proprietaire.mainloop()
merci pour toute aide