⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ extension ttk ⇨ Treeview
tkinter.ttk.Treeview ( ).focus ( )
⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ extension ttk ⇨ Treeview
tkinter.ttk.Treeview ( ).focus ( )
DESCRIPTION.
Donne le focus à l'un des éléments d'un objet tkinter.ttk.Treeview ( ).
SYNTAXE.
TRV_Tableau.focus ( element )
TRV_Tableau ⇨ instance de tkinter.ttk.Treeview ( ) [ OBLIGATOIRE ]
.focus ( ) ⇨ appel de la méthode [ OBLIGATOIRE ]
element ⇨ identifiant de l'élément [ OBLIGATOIRE ]
REMARQUES.
element est un str ( ) désignant l'identifiant d'un élément de l'arborescence. L'identifiant d'un élément est la chaine de caractères donnée en troisième argument dans la méthode tkinter.ttk.Treeview ( ).insert ( ). Si element n'existe pas Python lèvera une exception.
Si element est absent, la méthode tkinter.Spinbox ( ).focus ( ) retourne l'identifiant de l'élément qui a actuellement le focus.
EXEMPLE.
import tkinter , tkinter.ttk
TPL_Fruits = ( "Pomme" , "Poire" , "Cerise" , "Fraise" , "Banane" , "Pêche" , "Abricot" )
def FNC_Focus ( ) :
TRV_Fruits.focus ( SPI_Fruits.get ( ) )
LAB_Focus [ "text" ] = f"{ TRV_Fruits.focus ( ) } a le focus ..."
TKI_Principal = tkinter.Tk ( )
BUT_Quitter = tkinter.Button ( TKI_Principal , text = "Quitter" , command = TKI_Principal.destroy )
SPI_Fruits = tkinter.Spinbox ( TKI_Principal , values = TPL_Fruits , command = FNC_Focus )
TRV_Fruits = tkinter.ttk.Treeview ( TKI_Principal )
LAB_Focus = tkinter.Label ( TKI_Principal )
TRV_Fruits.heading ( "#0" , text = "Fruits" )
for kfruit in TPL_Fruits : TRV_Fruits.insert ( "" , "end" , kfruit , text = f"Le mot : { kfruit } a { len ( kfruit ) } lettres" )
TRV_Fruits.pack ( )
SPI_Fruits.pack ( )
LAB_Focus.pack ( )
BUT_Quitter.pack ( )
TKI_Principal.mainloop ( )
Votre aide est précieuse pour améliorer ce site, alors n'hésitez pas à faire part de