⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ liste des attributs
tkinter.scrollregion
⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ liste des attributs
tkinter.scrollregion
DESCRIPTION.
Définit ou retourne les coordonnées des sommets de la zone de confinement, accessibles par défilement, d'un controle.
SYNTAXE.
scrollregion = ( gauche , haut , droite , bas )
REMARQUES.
gauche, haut, droite et bas doivent être des int ( ). qui peuvent être négatif, qui s'exprime en pixels. Les barres de défilements associées au controle, un objet tkinter.Canvas ( ), pourront atteindre uniquement les parties de la toile comprises dans les limites de la zone de confinement, à moins que l'attribut confine du controle est la valeur False, ce qui permettrait de naviguer au delà de cette zone restreinte.
Le comportement de cet attribut, peut varier selon la combinaison controle / environnement utilisée. Il peut même, dans certain cas, être ignoré.
EXEMPLE.
import tkinter
def FNC_Visuel ( event ) :
knord = SCA_Haut.get ( )
ksud = SCA_Bas.get ( )
kouest = SCA_Gauche.get ( )
kest = SCA_Droite.get ( )
kconfine = "True" if TKV_Confine.get ( ) else "False"
CAN_Toile [ "scrollregion" ] = ( kouest , knord , kest , ksud )
CAN_Toile [ "confine" ] = TKV_Confine.get ( )
kcode = f"scrollregion = ( { kouest } , { knord } , { kest } , { ksud } )"
kcode += f"\net confine = { kconfine }"
LAB_Code [ "text" ] = kcode
TKI_Principal = tkinter.Tk ( )
TKV_Confine = tkinter.BooleanVar ( )
BUT_Quitter = tkinter.Button ( TKI_Principal , text = "Quitter" , command = TKI_Principal.destroy )
SCA_Haut = tkinter.Scale ( TKI_Principal , orient = "horizontal" , label = "Haut" , from_ = -200 , to = 500 , command = FNC_Visuel )
SCA_Bas = tkinter.Scale ( TKI_Principal , orient = "horizontal" , label = "Bas" , from_ = 200 , to = 900 , command = FNC_Visuel )
SCA_Gauche = tkinter.Scale ( TKI_Principal , orient = "horizontal" , label = "Gauche" , from_ = -200 , to = 500 , command = FNC_Visuel )
SCA_Droite = tkinter.Scale ( TKI_Principal , orient = "horizontal" , label = "Droite" , from_ = 200 , to = 900 , command = FNC_Visuel )
CKB_Confine = tkinter.Checkbutton ( TKI_Principal , text = "confine" , variable = TKV_Confine , command = lambda : FNC_Visuel ( None ) )
BAR_Cote = tkinter.Scrollbar ( TKI_Principal )
BAR_Bas = tkinter.Scrollbar ( TKI_Principal , orient = "horizontal" )
LAB_Code = tkinter.Label ( TKI_Principal )
CAN_Toile = tkinter.Canvas ( TKI_Principal , bg = "white" , width = 300 , height = 300 )
for kligne in range ( 9 ) :
CAN_Toile.create_line ( 0 , ( kligne * 100 ) , 800 , ( kligne * 100 ) , fill = "black" )
CAN_Toile.create_line ( ( kligne * 100 ) , 0 , ( kligne * 100 ) , 800 , fill = "black" )
CAN_Toile.create_rectangle ( 10 , 10 , 110 , 110 , fill = "pink" )
CAN_Toile.create_rectangle ( 290 , 10 , 390 , 110 , fill = "red" )
CAN_Toile.create_rectangle ( 10 , 290 , 110 , 390 , fill = "green" )
CAN_Toile.create_rectangle ( 290 , 290 , 390 , 390 , fill = "blue" )
CAN_Toile.create_rectangle ( 180 , 130 , 570 , 170 , fill = "yellow" )
CAN_Toile.create_rectangle ( 130 , 180 , 170 , 570 , fill = "orange" )
CAN_Toile [ "xscrollcommand" ] = BAR_Bas.set
CAN_Toile [ "yscrollcommand" ] = BAR_Cote.set
BAR_Bas [ "command" ] = CAN_Toile.xview
BAR_Cote [ "command" ] = CAN_Toile.yview
CAN_Toile.grid ( row = 0 , column = 0 , sticky = "nesw" )
BAR_Cote.grid ( row = 0 , column = 1 , sticky = "nesw" )
BAR_Bas.grid ( row = 1 , column = 0 , sticky = "nesw" )
LAB_Code.grid ( row = 2 , column = 0 , sticky = "nesw" )
CKB_Confine.grid ( row = 3 , column = 0 , sticky = "nesw" )
SCA_Haut.grid ( row = 4 , column = 0 , sticky = "nesw" )
SCA_Bas.grid ( row = 5 , column = 0 , sticky = "nesw" )
SCA_Gauche.grid ( row = 6 , column = 0 , sticky = "nesw" )
SCA_Droite.grid ( row = 7 , column = 0 , sticky = "nesw" )
BUT_Quitter.grid ( row = 8 , column = 0 , sticky = "nesw" )
TKV_Confine.set ( CAN_Toile [ "confine" ] )
SCA_Bas.set ( 500 )
SCA_Droite.set ( 500 )
TKI_Principal.mainloop ( )
Votre aide est précieuse pour améliorer ce site, alors n'hésitez pas à faire part de