tkinter.font --- Tkinter font wrapper¶
Code source : Lib/tkinter/font.py
The tkinter.font module provides the Font class for creating
and using named fonts.
Les différentes épaisseurs et inclinaisons des polices sont :
- class tkinter.font.Font(root=None, font=None, name=None, exists=False, **options)¶
La classe
Fontreprésente une police nommée. Les instances Font reçoivent des noms uniques et peuvent être spécifiées par leur configuration de famille, de taille et de style. Les polices nommées sont la méthode de Tk pour créer et identifier les polices comme un seul objet, plutôt que de spécifier une police par ses attributs à chaque occurrence.Modifié dans la version 3.10: Two fonts now compare equal (
==) only when both areFontinstances with the same name belonging to the same Tcl interpreter.arguments :
font – n-uplet spécificateur de police (famille, taille, options)name – nom de police uniqueexists – s'il est vrai, self pointe vers la police nommée existanteoptions nommées supplémentaires (ignorées si font est spécifié) :
family - font family, for example, Courier, Timessize – taille de la policeSi size est positif, il est interprété comme une taille en points.Si size est un nombre négatif sa valeur absolue est traitéecomme taille en pixels.weight – accentuation de la police (NORMAL, BOLD pour gras)slant – ROMAN pour romain, ITALIC pour italiqueunderline – soulignement de la police (0 – aucun, 1 – souligné)overstrike – police barrée (0 – aucune, 1 – barré)- actual(option=None, displayof=None)¶
Return the actual attributes of the font, which may differ from the requested ones because of platform limitations. With no option, return a dictionary of all the attributes; if option is given, return the value of that single attribute.
- cget(option)¶
Récupère un attribut de la police.
- configure(**options)¶
Modify one or more attributes of the font. With no arguments, return a dictionary of the current attributes.
config()is an alias ofconfigure().
- copy()¶
Renvoie une nouvelle instance de la police actuelle.
- measure(text, displayof=None)¶
Return amount of space the text would occupy on the specified display when formatted in the current font, as an integer number of pixels. If no display is specified then the main application window is assumed.
- metrics(*options, **kw)¶
Return font-specific data. With no options, return a dictionary mapping each metric name to its integer value; if one option name is given, return that metric's value as an integer. Options include:
- ascent – distance entre la ligne de base et le point le plus haut qu'un
caractère de la police peut occuper
- descent – distance entre la ligne de base et le point le plus bas qu'un
caractère de la police peut occuper
- linespace – séparation verticale minimale nécessaire entre deux
caractères de la police qui assure l'absence de chevauchement vertical entre les lignes.
fixed – 1 si la police est à largeur fixe sinon 0
- tkinter.font.families(root=None, displayof=None)¶
Return a tuple of the names of the available font families.
- tkinter.font.names(root=None)¶
Return a tuple of the names of all the defined fonts.