⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ liste des attributs
tkinter.undo
⇨ MENU ⇨ MODULES ⇨ tkinter ⇨ liste des attributs
tkinter.undo
DESCRIPTION.
Définit s'il sera possible d'annuler, ou non, les modifications apportées au contenu d'un éditeur de texte.
SYNTAXE.
undo = booleen
REMARQUES.
booleen est un bool ( ). Si undo = True, les modifications apportées au contenu de l'éditeur de texte pourront être annulées, ou rétablies après annulation. Tant que undo = False, aucune modifications ne pourra être annulée ou rétablie.
Plus précisément, undo = True autorise la prise en compte des appels des méthodes tkinter.Text ( ).edit_undo ( ) et tkinter.Text ( ).edit_redo ( ), alors qu'avec undo = False, les appels à ces méthodes seront simplement ignorés.
Voir gestion de l'historique d'annulation des éditeurs de texte pour plus de détails.
EXEMPLE.
import tkinter
def FNC_Annuler ( ) :
TXT_Editeur.edit_undo ( )
def FNC_Automatique ( ) :
if "manuels" in BUT_Gestion [ "text" ] :
BUT_Gestion [ "text" ] = "Séparateurs automatiques"
TXT_Editeur [ "autoseparators" ] = False
BUT_Separateur [ "state" ] = "normal"
else :
BUT_Gestion [ "text" ] = "Séparateurs manuels"
TXT_Editeur [ "autoseparators" ] = True
BUT_Separateur [ "state" ] = "disabled"
def FNC_Autoriser ( ) :
if "Interdire" in BUT_Activer [ "text" ] :
BUT_Activer [ "text" ] = "Autoriser les annulations"
TXT_Editeur [ "undo" ] = False
else :
BUT_Activer [ "text" ] = "Interdire les annulations"
TXT_Editeur [ "undo" ] = True
def FNC_Retablir ( ) :
TXT_Editeur.edit_redo ( )
def FNC_Separateur ( ) :
TXT_Editeur.edit_separator ( )
TKI_Principal = tkinter.Tk ( )
BUT_Quitter = tkinter.Button ( TKI_Principal , text = "Quitter" , command = TKI_Principal.destroy )
BUT_Annuler = tkinter.Button ( TKI_Principal , text = "Annuler les modifications" , command = FNC_Annuler )
BUT_Retablir = tkinter.Button ( TKI_Principal , text = "Rétablir les modifications" , command = FNC_Retablir )
BUT_Activer = tkinter.Button ( TKI_Principal , text = "Interdire les annulations" , command = FNC_Autoriser )
BUT_Gestion = tkinter.Button ( TKI_Principal , text = "Séparateurs manuels" , command = FNC_Automatique )
BUT_Separateur = tkinter.Button ( TKI_Principal , text = "Placer un séparateur" , command = FNC_Separateur )
TXT_Editeur = tkinter.Text ( TKI_Principal , undo = True , autoseparators = True , maxundo = 25 , width = 25 , height = 8 )
TXT_Editeur.pack ( )
BUT_Annuler.pack ( fill = "both" )
BUT_Retablir.pack ( fill = "both" )
BUT_Activer.pack ( fill = "both" )
BUT_Gestion.pack ( fill = "both" )
BUT_Separateur.pack ( fill = "both" )
BUT_Quitter.pack ( fill = "both" )
BUT_Separateur [ "state" ] = "disabled"
TXT_Editeur.insert ( "1.0" , "Python est un langage de programmation puissant et facile à apprendre." )
TXT_Editeur.insert ( "end + 1 line" , "\n\n" )
TXT_Editeur.insert ( "end + 1 line" , "Python is an easy to learn, powerful programming language." )
TKI_Principal.mainloop ( )
Votre aide est précieuse pour améliorer ce site, alors n'hésitez pas à faire part de