⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ liste des méthodes
tkinter.winfo_rgb ( )
⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ liste des méthodes
tkinter.winfo_rgb ( )
DESCRIPTION.
Retourne les quantités des couleurs primaires composant une couleur.
SYNTAXE.
TPL_Quota = widget.winfo_rgb ( couleur )
TPL_Quota = ⇨ variable qui recevra les valeur [ optionnel ]
widget ⇨ controle quelconque de l'interface [ OBLIGATOIRE ]
.winfo_rgb ( ) ⇨ appel de la méthode [ OBLIGATOIRE ]
couleur ⇨ couleur à décomposer [ OBLIGATOIRE ]
REMARQUES.
couleur est un str ( ) correspondant à un nom standardisé de couleur tel que : "while", "black", "red", "green", "blue", "cyan", "yellow", "magenta".
La méthode tkinter.winfo_rgb ( ) retourne un tuple ( ) de 3 éléments ( rouge , vert , bleu ). Chaque valeur est un int ( ) compris entre 0 et 65536. Voir Notions : les couleurs, pour plus d'informations sur la gestion des couleurs par Python et son module standard tkinter.
Par convention, on utilise la fenêtre créée avec tkinter.Tk ( ) pour l'utilisation de cette méthode.
EXEMPLE.
import tkinter
def FNC_Analyser ( ) :
kcode = "#"
kcouleur = ENT_Nom.get ( )
try :
LAB_Brut [ "text" ] = f"{ kcouleur } vaut { TKI_Principal.winfo_rgb ( kcouleur ) }"
for kprimaire in TKI_Principal.winfo_rgb ( kcouleur ) :
kquantite = "0000" + hex ( kprimaire ) [ 2 : ]
kquantite = kquantite [ len ( kquantite ) - 4 : ]
kcode = kcode + kquantite
LAB_Analyse [ "text" ] = f"son codage est { kcode }"
except :
LAB_Brut [ "text" ] = f"{ kcouleur } n'est pas un nom"
LAB_Analyse [ "text" ] = "de couleur valide."
TKI_Principal = tkinter.Tk ( )
BUT_Quitter = tkinter.Button ( TKI_Principal , text = "Quitter" , command = TKI_Principal.destroy )
BUT_Analyse = tkinter.Button ( TKI_Principal , text = "Analyser" , command = FNC_Analyser )
ENT_Nom = tkinter.Entry ( TKI_Principal , width = 25 )
LAB_Brut = tkinter.Label ( TKI_Principal )
LAB_Analyse = tkinter.Label ( TKI_Principal )
ENT_Nom.grid ( row = 0 , column = 0 , sticky = "nesw" )
BUT_Analyse.grid ( row = 0 , column = 1 , sticky = "nesw" )
LAB_Brut.grid ( row = 1 , column = 0, columnspan = 2 , sticky = "nesw" )
LAB_Analyse.grid ( row = 2 , column = 0, columnspan = 2 , sticky = "nesw" )
BUT_Quitter.grid ( row = 3 , column = 0 , columnspan = 2 , sticky = "nesw" )
TKI_Principal.mainloop ( )
Votre aide est précieuse pour améliorer ce site, alors n'hésitez pas à faire part de