⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ liste des attributs
tkinter.justify
⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ liste des attributs
tkinter.justify
DESCRIPTION.
Définit ou retourne l'alignement du texte, ou du contenu, du contorle s'il est constitué de plusieurs lignes.
SYNTAXE.
justify = alignement
REMARQUES.
alignement doit être un str ( ) représentant un alignement valide. Les alignements valides sont :
- "left" : toutes les lignes sont alignées sur la gauche ;
- "center" : toutes les lignes sont centées ;
- "right" : toutes les lignes sont alignées sur la droite.
L'attribut justify permet de choisir l'alignement des lignes entre elles, mais pas dans le controle. Voir l'attribut anchor pour choisir la position du contenu dans le controle.
EXEMPLE.
import tkinter
def FNC_Alignement ( Q ) :
LAB_Temoin [ "justify" ] = Q
FNC_Attibuts ( )
def FNC_Ancre ( event ) :
kancre = BOX_Ancres.get ( BOX_Ancres.curselection ( ) )
LAB_Temoin [ "anchor" ] = kancre
FNC_Attibuts ( )
def FNC_Attibuts ( ) :
kalignement = LAB_Temoin [ "justify" ]
kancre = LAB_Temoin [ "anchor" ]
LAB_Temoin [ "text" ] = f'Mon Pyhon à moi.\nanchor = "{ kancre }"\njustify = "{ kalignement }"'
TKI_Principal = tkinter.Tk ( )
BUT_Quitter = tkinter.Button ( TKI_Principal , text = "Quitter" , command = TKI_Principal.destroy )
BUT_Gauche = tkinter.Button ( TKI_Principal , text = "left" , command = lambda : FNC_Alignement ( "left" ) )
BUT_Milieu = tkinter.Button ( TKI_Principal , text = "center" , command = lambda : FNC_Alignement ( "center" ) )
BUT_Droite = tkinter.Button ( TKI_Principal , text = "right" , command = lambda : FNC_Alignement ( "right" ) )
BOX_Ancres = tkinter.Listbox ( TKI_Principal , height = 9 , width = 7 )
LAB_Temoin = tkinter.Label ( TKI_Principal , relief = "solid" , bd = 3 , height = 5 , width = 25 )
BOX_Ancres.grid ( row = 0 , column = 0 , rowspan = 3 , sticky = "nesw" )
LAB_Temoin.grid ( row = 0 , column = 1 , columnspan = 3 , sticky = "nesw" )
BUT_Gauche.grid ( row = 1 , column = 1 , sticky = "nesw" )
BUT_Milieu.grid ( row = 1 , column = 2 , sticky = "nesw" )
BUT_Droite.grid ( row = 1 , column = 3 , sticky = "nesw" )
BUT_Quitter.grid ( row = 2 , column = 1 , columnspan = 3 , sticky = "nesw" )
for kancre in ( "n" , "ne" , "e" , "se" , "s" , "sw" , "w" , "nw" , "center" ) :
BOX_Ancres.insert ( "end" , kancre )
BOX_Ancres.bind ( "<ButtonRelease>" , FNC_Ancre )
BOX_Ancres.bind ( "<KeyRelease-Up>" , FNC_Ancre )
BOX_Ancres.bind ( "<KeyRelease-Down>" , FNC_Ancre )
FNC_Alignement ( "center" )
BOX_Ancres.select_set ( 0 )
BOX_Ancres.focus_force ( )
FNC_Attibuts ( )
TKI_Principal.mainloop ( )
Votre aide est précieuse pour améliorer ce site, alors n'hésitez pas à faire part de