⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ liste des méthodes
tkinter.focus_set ( )
⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ liste des méthodes
tkinter.focus_set ( )
DESCRIPTION.
Donne le focus au controle appelant.
SYNTAXE.
widget.focus_set ( )
widget ⇨ controle quelconque de l'interface [ OBLIGATOIRE ]
.focus_set ( ) ⇨ appel de la méthode [ OBLIGATOIRE ]
REMARQUES.
tkinter.focus_set ( ) donne le focus au controle appelant si l'application est le programme actuellement actif sinon le controle appelant aura le focus quand le l'application sera le programme actif.
Le focus désigne la focalisation du clavier. Quand un controle obtient, reçoit, acquièrent, le focus c'est vers lui que les saisies, faites au clavier par l’utilisateur, seront dirigées.
EXEMPLE.
import tkinter
def FNC_Message ( event ) :
LAB_Focus [ "text" ] = f"{ TKI_Principal.focus_lastfor ( ) } a le focus."
TKI_Principal = tkinter.Tk ( )
BUT_Quitter = tkinter.Button ( TKI_Principal , text = "Quitter" , command = TKI_Principal.destroy )
ENT_A = tkinter.Entry ( TKI_Principal )
ENT_B = tkinter.Entry ( TKI_Principal )
ENT_C = tkinter.Entry ( TKI_Principal )
BUT_A = tkinter.Button ( TKI_Principal , text = "focus⇒" , command = ENT_A.focus_set )
BUT_B = tkinter.Button ( TKI_Principal , text = "focus⇘" , command = ENT_C.focus_set )
BUT_C = tkinter.Button ( TKI_Principal , text = "focus⇗" , command = ENT_B.focus_set )
LAB_Focus = tkinter.Label ( TKI_Principal , text = "focus ?" )
TKI_Principal.bind ( "<FocusOut>" , FNC_Message )
TKI_Principal.bind ( "<FocusIn>" , FNC_Message )
ENT_A.bind ( "<FocusIn>" , FNC_Message )
ENT_B.bind ( "<FocusIn>" , FNC_Message )
ENT_C.bind ( "<FocusIn>" , FNC_Message )
LAB_Focus.grid ( row = 0 , column = 0 , columnspan = 2 , sticky = "nesw" )
BUT_A.grid ( row = 1 , column = 0 , sticky = "nesw" )
ENT_A.grid ( row = 1 , column = 1 , sticky = "nesw" )
BUT_B.grid ( row = 2 , column = 0 , sticky = "nesw" )
ENT_B.grid ( row = 2 , column = 1 , sticky = "nesw" )
BUT_C.grid ( row = 3 , column = 0 , sticky = "nesw" )
ENT_C.grid ( row = 3 , column = 1 , sticky = "nesw" )
BUT_Quitter.grid ( row = 0 , column = 2 , rowspan = 4 , sticky = "nesw" )
FNC_Message ( None )
TKI_Principal.mainloop ( )
Votre aide est précieuse pour améliorer ce site, alors n'hésitez pas à faire part de