⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ extension ttk ⇨ Treeview
tkinter.ttk.Treeview ( ).detach ( )
⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ extension ttk ⇨ Treeview
tkinter.ttk.Treeview ( ).detach ( )
DESCRIPTION.
Cache, sans les supprimer, des éléments d'un objet tkinter.ttk.Treeview ( ).
SYNTAXE.
TRV_Tableau.detach ( elementA , ... , elementN )
TRV_Tableau ⇨ instance de tkinter.ttk.Treeview ( ) [ OBLIGATOIRE ]
.detach ( ) ⇨ 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, ou n'existe plus, Python lèvera une exception.
Pour cacher plusieurs éléments en un seul appel de la méthode tkinter.ttk.Treeview ( ).detach ( ), il faut séparer leur identifiant par une virgule.
Si element est un noeud interne, tous ses enfants, seront cachés aussi.
L'élément racine, identifié par "", ne peut pas être caché.
Voir la méthode tkinter.ttk.Treeview ( ).move ( ) pour afficher des éléments cachés.
Voir la méthode tkinter.ttk.Treeview ( ).delete ( ) pour supprimer définitivement des éléments.
EXEMPLE.
import tkinter , tkinter.ttk
def FNC_Action ( ) :
if "Cache" in BUT_Action [ "text" ] :
BUT_Action [ "text" ] = "Montrer Européens"
TRV_Pays.detach ( "B" , "S" )
else :
BUT_Action [ "text" ] = "Cacher Européens"
TRV_Pays.move ( "B" , "" , 0 )
TRV_Pays.move ( "S" , "" , "end" )
TKI_Principal = tkinter.Tk ( )
BUT_Quitter = tkinter.Button ( TKI_Principal , text = "Quitter" , command = TKI_Principal.destroy )
BUT_Action = tkinter.Button ( TKI_Principal , text = "Cacher Européens" , command = FNC_Action )
TRV_Pays = tkinter.ttk.Treeview ( TKI_Principal , columns = ( "Capital" ) )
TRV_Pays.insert ( "" , "end" , "B" , text = "Belgique" , values = ( "Bruxelles" ) )
TRV_Pays.insert ( "" , "end" , "C" , text = "Canada" , values = ( "Quebec" ) )
TRV_Pays.insert ( "" , "end" , "L" , text = "Liban" , values = ( "Beyrouth" ) )
TRV_Pays.insert ( "" , "end" , "S" , text = "Suisse" , values = ( "Berne" ) )
TRV_Pays.pack ( )
BUT_Action.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