⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ liste des attributs
tkinter.confine
⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ liste des attributs
tkinter.confine
DESCRIPTION.
Définit ou retourne si la zone de visualisation du controle sera restreinte à la zone de défilement (scrollregion) du controle.
SYNTAXE.
confine = booleen
REMARQUES.
booleen est un bool ( ). Si confine = True, les barres de défilement associées au controle, un objet tkinter.Canvas ( ), pourront atteindre des zones du controle en dehors de la zone de défilement définie par l'attribut scrollregion. Si confine = False, seule la zone de défilement sera accessible par les barres de défilement.
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