⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ controles standards ⇨ Text
tkinter.Text ( ).yview_moveto ( )
⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ controles standards ⇨ Text
tkinter.Text ( ).yview_moveto ( )
DESCRIPTION.
Définit l'ordonnée, relative, du bord haut de la zone visible d'un éditeur de texte.
SYNTAXE.
TXT_Editeur.yview_moveto ( ordonnee )
TXT_Editeur ⇨ instance quelconque de tkinter.Canvas ( ) [ OBLIGATOIRE ]
.yview_moveto ( ) ⇨ appel de la méthode [ OBLIGATOIRE ]
ordonnee ⇨ ordonnée relative du début de la zone visible [ OBLIGATOIRE ]
REMARQUES.
ordonnee est un float ( ) compris entre en 0.0 et 1.0, où :
- 0.0 représente du bord haut où débutent les lignes de l'éditeur de texte ;
- 1.0 représente du bord bas où se terminent les lignes de l'éditeur de texte.
L'intervalle (0, 1) représente la hauteur totale de l'éditeur de texte. La première ligne visible d'un éditeur de texte sera, après déplacement verticale de son contenu, celle correspondant à ordonnee.
ordonnee correspond au premier élément du tuple ( ) retourné par la méthode tkinter.Text ( ).yview ( ).
EXEMPLE.
import tkinter , tkinter.filedialog
def FNC_Action ( event ) :
TXT_Editeur.xview_moveto ( SCA_Abscisse.get ( ) )
TXT_Editeur.yview_moveto ( SCA_Ordonnee.get ( ) )
kdebut = int ( TXT_Editeur.xview ( ) [ 0 ] * 100 )
kfin = int ( TXT_Editeur.xview ( ) [ 1 ] * 100 )
LAB_Horizontal [ "text" ] = f"La partie horizontale visible va :\n{ kdebut }% à { kfin }%."
kdebut = int ( TXT_Editeur.yview ( ) [ 0 ] * 100 )
kfin = int ( TXT_Editeur.yview ( ) [ 1 ] * 100 )
LAB_Vertical [ "text" ] = f"La partie verticale visible va :\n{ kdebut }% à { kfin }%."
def FNC_Ouvrir ( ) :
kextentions = [ ( "texte" , ".txt" ) , ( "python" , ".py" ) ]
kfichier = tkinter.filedialog.askopenfilename ( title = "Ouvrir" , filetypes = kextentions )
if len ( kfichier ) < 1 : return
TXT_Editeur.delete ( "1.0" , "end" )
with open ( kfichier ) as FIL_Fichier : TXT_Editeur.insert ( "end" , FIL_Fichier.read ( ) )
FNC_Action ( None )
TKI_Principal = tkinter.Tk ( )
BUT_Quitter = tkinter.Button ( TKI_Principal , text = "Quitter le test" , command = TKI_Principal.destroy )
BUT_Ouvrir = tkinter.Button ( TKI_Principal , text = "Ouvrir un fichier" , command = FNC_Ouvrir )
SCA_Abscisse = tkinter.Scale ( TKI_Principal , orient = "horizontal" , to = 1 , resolution = .05 , command = FNC_Action )
SCA_Ordonnee = tkinter.Scale ( TKI_Principal , to = 1 , resolution = .05 , command = FNC_Action )
LAB_Horizontal = tkinter.Label ( TKI_Principal , relief = "solid" , height = 3 )
LAB_Vertical = tkinter.Label ( TKI_Principal , relief = "solid" , height = 3 )
TXT_Editeur = tkinter.Text ( TKI_Principal , wrap = "none" , width = 40 , height = 12 )
SCA_Abscisse.grid ( row = 0 , column = 1 , sticky = "nesw" )
SCA_Ordonnee.grid ( row = 1 , column = 0 , sticky = "nesw" )
TXT_Editeur.grid ( row = 1 , column = 1 , sticky = "nesw" )
LAB_Horizontal.grid ( row = 2 , column = 1 , sticky = "nesw" )
LAB_Vertical.grid ( row = 3 , column = 1 , sticky = "nesw" )
BUT_Ouvrir.grid ( row = 4 , column = 1 , sticky = "nesw" )
BUT_Quitter.grid ( row = 5 , column = 1 , sticky = "nesw" )
TXT_Editeur.insert ( "1.0" , "Tapez un texte ou\nouvrez un fichier txt ou py." )
SCA_Abscisse.set ( .25 )
SCA_Ordonnee.set ( .25 )
FNC_Action ( None )
TKI_Principal.mainloop ( )
Votre aide est précieuse pour améliorer ce site, alors n'hésitez pas à faire part de