[PyQt] Undo Redo PyQt

Russell Valentine russ at coldstonelabs.org
Wed Jan 13 23:46:27 GMT 2010


Zabin Farishta wrote:
>  Hey!
> 
> I am trying to implement the undo and redo facility in pyqt. I have gone
> through some sites and was wondering whether iyou always need to
> create subclasses and their definitions for the undo/redo action. My program
> currently has a single window in which the user enters information which is
> used to update a text file as soon as the user
> leaves the field- so i essentially need to undo the text in that field as
> well as the file. I am puzzled as to how to approach this. Any help will be
> much appreciated!


You need to save the data somewhere every time it changes. For my app I 
pickle a document class every time something changes and keep a list of 
the pickle files. A undo/redo loads the pickled class to current and 
refresh. I delete all the pickle files on program exit. It might make 
sense in your case just to save the deltas. My app is used on images 
and it was just easier to pickle everything.


Russell Valentine


More information about the PyQt mailing list