⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ controles standards ⇨ Scrollbar
tkinter.Scrollbar ( ).fraction ( )
⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ controles standards ⇨ Scrollbar
tkinter.Scrollbar ( ).fraction ( )
DESCRIPTION.
Retourne la valeur relative de la position du curseur d'une barre de défilement aux coordonnées indiquées.
SYNTAXE.
Valeur = BAR_Ascenseur.fraction ( abscisse , ordonnee )
Valeur = ⇨ variable qui recevra la valeur [ optionnel ]
BAR_Ascenseur ⇨ instance quelconque de tkinter.Scrollbar ( ) [ OBLIGATOIRE ]
.fraction ( ) ⇨ appel de la méthode [ OBLIGATOIRE ]
abscisse ⇨ position horizontale [ OBLIGATOIRE ]
ordonnee ⇨ position verticale [ OBLIGATOIRE ]
REMARQUES.
abscisse et ordonnee doivent être des int ( ) ou float ( ), positifs, nuls ou négatifs exprimés en pixels le long de la glissière.
La méthode tkinter.Scrollbar ( ).fraction ( ) retourne un float ( ) compris entre 0.0 et 1.0, où :
- 0.0 représente le bord débutant la barre de défilement ;
- 1.0 représente le bord terminant la barre de défilement.
EXEMPLE.
import tkinter
def FNC_Valeur ( event ) :
kfraction = BAR_Temoin.fraction ( SCA_Abscisse.get ( ) , 0 )
LAB_Valeur [ "text" ] = f"Position\n{kfraction:.3f}"
TKI_Principal = tkinter.Tk ( )
BUT_Quitter = tkinter.Button ( TKI_Principal , text = "Quitter" , command = TKI_Principal.destroy )
BAR_Temoin = tkinter.Scrollbar ( TKI_Principal , orient = "horizontal" )
ENT_Saisie = tkinter.Entry ( TKI_Principal )
SCA_Abscisse = tkinter.Scale ( TKI_Principal , from_ = -10 , to = 300 , orient = "horizontal" , command = FNC_Valeur )
LAB_Valeur = tkinter.Label ( TKI_Principal , width = 10 )
ENT_Saisie [ "xscrollcommand" ] = BAR_Temoin.set
BAR_Temoin [ "command" ] = ENT_Saisie.xview
ENT_Saisie.insert ( "end" , "Python est puissant et agréable à apprendre. Il convient à tous les projets, simples ou complexes." )
ENT_Saisie.grid ( row = 0 , column = 0 , columnspan = 3 , sticky = "nesw" )
BAR_Temoin.grid ( row = 1 , column = 0 , columnspan = 3 , sticky = "nesw" )
LAB_Valeur.grid ( row = 2 , column = 0 , sticky = "nesw" )
SCA_Abscisse.grid ( row = 2 , column = 1 , sticky = "nesw" )
BUT_Quitter.grid ( row = 2 , column = 2 , sticky = "nesw" )
TKI_Principal.mainloop ( )
Votre aide est précieuse pour améliorer ce site, alors n'hésitez pas à faire part de