⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ controles standards ⇨ Font
tkinter.font.nametofont ( )
⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ controles standards ⇨ Font
tkinter.font.nametofont ( )
DEFINITION.
Crée un nouvel objet fonte, un clone, en lui donnant les caractéristiques d'un objet fonte existant.
SYNTAXE.
FNT_Fonte = tkinter.font.nametofont ( fonte )
FNT_Fonte = ⇨ nouvel objet fonte [ optionnel ]
tkinter.font.nametofont ( ) ⇨ appel de la méthode [ OBLIGATOIRE ]
fonte ⇨ objet fonte de référence [ OBLIGATOIRE ]
REMARQUES.
La méthode tkinter.font.nametofont ( ) n'est pas native du module tkinter, il faut donc commencer par importer le module tkinter.font pour pouvoir utiliser cette méthode. Voir import pour plus de détails sur l'incorporation de modules, classes et méthodes non built-in dans un script.
fonte doit être un l'identifiant d'un objet fonte valide, existant et vivant.
La méthode tkinter.font.nametofont ( ) créer un nouvel emballage pour un objet fonte déjà existant. Elle est la plus part du temps utilisée avec les fontes créés à l'initialisation du module tkinter qui sont : "TkCaptionFont" ; "TkDefaultFont" ; "TkFixedFont" ; "TkHeadingFont" ; "TkIconFont" ; "TkMenuFont" ; "TkSmallCaptionFont" ; "TkTextFont" ; "TkTooltipFont".
La méthode tkinter.font.nametofont ( ) ne détruit pas l'ancienne référence à fonte. L'objet fonte créé est indépendant de fonte. La modification de l'un des deux ne modifie pas l'autre objet fonte.
EXEMPLE.
import tkinter
import tkinter.font
TKI_Principal = tkinter.Tk ( )
FNT_Defaut = tkinter.font.Font ( font = "TkDefaultFont" )
FNT_Test = tkinter.font.Font ( family = "Script" , size = 16 , underline = True )
FNT_Clone = tkinter.font.Font ( font = FNT_Test )
FNT_Clone.config ( size = 8 , slant = "italic" , underline = False )
tkinter.Label ( TKI_Principal , text = "FNT_Defaut" , font = FNT_Defaut ).pack ( )
tkinter.Label ( TKI_Principal , text = "FNT_Test" , font = FNT_Test ).pack ( )
tkinter.Label ( TKI_Principal , text = "FNT_Clone" , font = FNT_Clone ).pack ( )
tkinter.Button ( TKI_Principal , text = "Quitter" , command = TKI_Principal.destroy ).pack ( )
TKI_Principal.mainloop ( )
Votre aide est précieuse pour améliorer ce site, alors n'hésitez pas à faire part de