A Practical Introduction to PyQt's Undo/Redo Framework

Every user experiences the occasional "oops." Luckily for most of us, smart programmers anticipate the possibility and provide undo/redo facilities to help us out of such jams. Mark Summerfield shows you how to be that smart sort of Python programmer, with this introduction to PyQt's undo/redo framework.

From the author of

Creating native and good-looking cross-platform applications is just about as
easy and pleasant as it can get when you use PyQt (the Python bindings for the
Qt application development framework), especially if you design your forms
visually using Qt Designer. Using QActions or direct signal-slot
connections, you can invoke any callable you like in response to user
interaction, such as when the user clicks a button or chooses a menu option.

This application shows one feature that’s common to many PyQt (and
C++/Qt) applications: Each action is connected directly to a method that carries
out the action. This is easy to program and maintain. As I’ll show
shortly, however, you must take a slightly different approach if you want to
provide undo/redo facilities.