⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ liste des méthodes
tkinter.keys ( )
⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ liste des méthodes
tkinter.keys ( )
DESCRIPTION.
Retourne la liste de tous les attributs d'un controle.
SYNTAXE.
LST_Atributs = widget.keys ( )
LST_Atributs = ⇨ variable qui recevra la liste des attributs [ optionnel ]
widget ⇨ controle quelconque de l'interface [ OBLIGATOIRE ]
.keys ( ) ⇨ appel de la méthode [ OBLIGATOIRE ]
REMARQUE.
L’utilisation de widget.keys ( ) retourne une list ( ) contenant tous les noms des attributs du controle widget.
EXEMPLE.
import tkinter
def FNC_Lecture ( Q ) :
kattributs = Q.keys ( )
kidentifiant = Q.winfo_id ( )
knom = Q.winfo_pathname ( kidentifiant )
LAB_Controle [ "text" ] = f"{ kidentifiant }\n{ knom }"
BOX_Attributs.delete ( 0 , "end" )
for kattribut in kattributs :
kvaleur = Q.cget ( kattribut )
kligne = f"{ kattribut } = { kvaleur }"
BOX_Attributs.insert ( "end" , kligne )
TKI_Principal = tkinter.Tk ( )
BUT_Quitter = tkinter.Button ( TKI_Principal , text = "Quitter" , command = TKI_Principal.destroy )
BUT_Bouton = tkinter.Button ( TKI_Principal , text = "Ce bouton" , command = lambda : FNC_Lecture ( BUT_Bouton ) )
BUT_Fenetre = tkinter.Button ( TKI_Principal , text = "La fenetre" , command = lambda : FNC_Lecture ( TKI_Principal ) )
BUT_Liste = tkinter.Button ( TKI_Principal , text = "La liste" , command = lambda : FNC_Lecture ( BOX_Attributs ) )
BUT_Etiquette = tkinter.Button ( TKI_Principal , text = "Le label" , command = lambda : FNC_Lecture ( LAB_Controle ) )
BOX_Attributs = tkinter.Listbox ( TKI_Principal , width = 25 )
LAB_Controle =tkinter.Label ( TKI_Principal , text = "faites un\nchoix..." , fg = "red" , bg = "yellow" )
BOX_Attributs.insert ( "end" , "en attente ..." )
BOX_Attributs.grid ( row = 0 , column = 0 , rowspan = 5 , sticky = "nesw" )
LAB_Controle.grid ( row = 0 , column = 1 , sticky = "nesw" )
BUT_Quitter.grid ( row = 0 , column = 2 , rowspan = 5 , sticky = "nesw" )
BUT_Bouton.grid ( row = 1 , column = 1 , sticky = "nesw" )
BUT_Fenetre.grid ( row = 2 , column = 1 , sticky = "nesw" )
BUT_Liste.grid ( row = 3 , column = 1 , sticky = "nesw" )
BUT_Etiquette.grid ( row = 4 , column = 1 , sticky = "nesw" )
TKI_Principal.mainloop ( )
Votre aide est précieuse pour améliorer ce site, alors n'hésitez pas à faire part de