⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ extension ttk ⇨ Treeview
tkinter.ttk.Treeview ( ).selection_set ( )
⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ extension ttk ⇨ Treeview
tkinter.ttk.Treeview ( ).selection_set ( )
DESCRIPTION.
Définit les éléments d'une sélection d'un objet tkinter.ttk.Treeview ( ).
SYNTAXE.
TRV_Tableau.selection_set ( elementA , ... , elementN )
TRV_Tableau ⇨ instance de tkinter.ttk.Treeview ( ) [ OBLIGATOIRE ]
.selection_set ( ) ⇨ 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.
Si aucun élément n'est indiqué, la sélection est complètement vidée. Si la sélection contenait d'autres éléments, ils sont retirés dans la sélection.
Pour placer plusieurs éléments en un seul appel de la méthode tkinter.ttk.Treeview ( ).selection_set ( ), il faut séparer leur identifiant par une virgule.
EXEMPLE.
import tkinter , tkinter.ttk
def FNC_Inverser ( ) :
TRV_Pays.selection_toggle ( "ca" , "su" , "be" , "fr" , "li" )
LAB_Selection [ "text" ] = TRV_Pays.selection ( )
def FNC_GroupeA ( ) :
TRV_Pays.selection_remove ( "su" , "be" , "li" )
TRV_Pays.selection_add ( "ca" , "fr" )
LAB_Selection [ "text" ] = TRV_Pays.selection ( )
def FNC_GroupeB ( ) :
TRV_Pays.selection_remove ( "ca" , "be" , "fr" )
TRV_Pays.selection_add ( "su" , "li" )
LAB_Selection [ "text" ] = TRV_Pays.selection ( )
def FNC_GroupeC ( ) :
TRV_Pays.selection_set ( "be" )
LAB_Selection [ "text" ] = TRV_Pays.selection ( )
TKI_Principal = tkinter.Tk ( )
BUT_Quitter = tkinter.Button ( TKI_Principal , text = "Quitter" , command = TKI_Principal.destroy )
BUT_Inverser = tkinter.Button ( TKI_Principal , text = "Inverver" , command = FNC_Inverser )
BUT_Ajouter = tkinter.Button ( TKI_Principal , text = "Goupe A" , command = FNC_GroupeA )
BUT_Retirer = tkinter.Button ( TKI_Principal , text = "Goupe B" , command = FNC_GroupeB )
BUT_Remplacer = tkinter.Button ( TKI_Principal , text = "Goupe C" , command = FNC_GroupeC )
LAB_Selection = tkinter.Label ( TKI_Principal )
TRV_Pays = tkinter.ttk.Treeview ( TKI_Principal )
TRV_Pays.heading ( "#0" , text = "Pays" )
TRV_Pays.insert ( "" , "end" , "ca" , text = "Canada" )
TRV_Pays.insert ( "" , "end" , "su" , text = "Suisse" )
TRV_Pays.insert ( "" , "end" , "be" , text = "Belgique" )
TRV_Pays.insert ( "" , "end" , "fr" , text = "France" )
TRV_Pays.insert ( "" , "end" , "li" , text = "Liban" )
TRV_Pays.grid ( row = 0 , column = 0 , columnspan = 5 )
BUT_Inverser.grid ( row = 1 , column = 0 )
BUT_Ajouter .grid ( row = 1 , column = 1 )
BUT_Retirer.grid ( row = 1 , column = 2 )
BUT_Remplacer .grid ( row = 1 , column = 3 )
BUT_Quitter.grid ( row = 1 , column = 4 )
LAB_Selection.grid ( row = 2 , column = 0 , columnspan = 5 )
TKI_Principal.mainloop ( )
Votre aide est précieuse pour améliorer ce site, alors n'hésitez pas à faire part de