Home > Articles > Open Source > Python

  • Print
  • + Share This
From the author of

Summary

This article has provided a brief introduction to PyQt’s undo/redo framework. I’ve shown you how to change the approach to performing actions, so that the actions are encapsulated in instances of custom QUndoCommand classes rather than performed directly. You’ve also learned how to pass all the undo/redo bookkeeping work to a QUndoStack. For actions that can’t be undone, you should give the user the opportunity to back out. Finally, I showed you how to use the undo/redo framework to provide a basic macro recording facility, provided that you’re careful to handle any actions that cannot be undone.

Retrofitting undo/redo to an existing application isn’t difficult, although it may require a lot of fairly repetitive work. Creating new applications that provide undo/redo and macros is straightforward, using the techniques shown here.

  • + Share This
  • 🔖 Save To Your Account