⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ extension ttk ⇨ Combobox
tkinter.ttk.Combobox ( ).current ( )
⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ extension ttk ⇨ Combobox
tkinter.ttk.Combobox ( ).current ( )
DESCRIPTION.
Place un élément de la liste à choix déroulante dans le sélecteur de cette liste à choix déroulante.
SYNTAXE.
CHX_Choix.current ( index )
CHX_Choix ⇨ instance de tkinter.ttk.Combobox ( ) [ OBLIGATOIRE ]
.current ( ) ⇨ appel de la méthode [ OBLIGATOIRE ]
index ⇨ index de l'élément à tester [ optionnel ]
REMARQUES.
index est un int ( ). Si idex est supérieur au nombre d'éléments de la liste à choix déroulante, Python lèvera un exception.
Si index est absent, la méthode tkinter.ttk.Combobox ( ).current ( ) retourne l'index de l'élément dans le sélecteur de la liste à choix déroulante, s'il existe, sinon -1.
Rappel : l'index du premier élément d'une liste fixe est 0.
EXEMPLE.
import tkinter , tkinter.ttk
def FNC_Selectionner ( event ) : CHX_Choix.current ( event )
TKI_Principal = tkinter.Tk ( )
CHX_Choix = tkinter.ttk.Combobox ( TKI_Principal , values = [ f"Ligne { kligne }" for kligne in range ( 30 ) ] )
CHX_Choix.pack ( )
tkinter.Scale ( TKI_Principal , orient = "horizontal" , to = 29 , command = FNC_Selectionner ).pack ( )
tkinter.Button ( TKI_Principal , text = "Quitter" , command = TKI_Principal.destroy ).pack ( )
FNC_Selectionner ( 0 )
TKI_Principal.mainloop ( )
Votre aide est précieuse pour améliorer ce site, alors n'hésitez pas à faire part de