[Tutor] Tkinter: checking a Text widget for contents/changes (original) (raw)
Alan Gauld alan.gauld at blueyonder.co.uk
Tue Jul 20 23:39:33 CEST 2004
- Previous message: [Tutor] Tkinter: checking a Text widget for contents/changes
- Next message: [Tutor] Re: removing line ends from Word text files
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I'm working on a simple text-editing application, and would like to include a function to ask the user to save changes before quitting. Can anyone describe a method for checking to see if anything has been entered into a Text widget's buffer
The classic way of doing this is to have a "dirty" flag. You set it to FAlse at startup and after a save. On any changes(text entry via keyboard or pasting etc) set the flag to True.
At exit or Save you can check
if dirty: self.SaveFile()
This means you have to bind an event handler to all the input events plus the load and save events handlers.
Not pretty but thats how its done in all the text editors I've worked on (that'd be precisely two! :-)
Alan G
- Previous message: [Tutor] Tkinter: checking a Text widget for contents/changes
- Next message: [Tutor] Re: removing line ends from Word text files
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]