- A Practical Introduction to PyQts Undo/Redo Framework
- Adding Undo/Redo to the Mix
- Using the Undo/Redo Framework
Adding Undo/Redo to the Mix
For a dialog box as simple as the one shown in Figure 1, undo/redo doesn’t make much sense, but for more complex dialog boxes and for main windows, providing users with undo/redo capabilities can improve an application’s usability considerably. With good undo/redo in place, support calls of the variety "I just messed up my last hour’s work and can’t find a way to undo my mistake" should practically disappear. So it isn’t just the user who benefits from the availability of undo/redo.
A dialog box like the one in Figure 2 allows the user to edit a list of strings. The strings could be filenames, the styles available in a word processing program, or any other sort of strings. A dialog box like this might take as its arguments 1) the name of the list for use in the title bar; and 2) the list of strings itself. The dialog box in Figure 2 has been called with a name of Movies and a list of movie title strings.
Figure 2 A string list editor dialog box.
The user might do a lot of work in this dialog box—adding, editing, removing, and moving the strings. But what happens if he accidentally deletes three or four strings? There’s no way to recall the deleted strings or to back out of the action, and the Close button simply commits whatever changes have been made. If you offer the ability to undo and redo user changes—not just one undo and one redo, but as many as needed—theoretically the user could undo every change back to when he first invoked the dialog box. Figure 3 shows an example.
Figure 3 A string list editor dialog box with undo/redo.