Hello, I define a couple QUndoCommand classes based on a mixin, where the undo command of one is the redo of the other, and vice-versa. See the attached file.
Unfortunately this has stopped working with PyQt 4.6. Executing the attached file prints "inserting foo", "removing bar" with PyQt <= 4.5, but does nothing with 4.6. Is this breakage expected? Is my usage not supported? Many thanks in advance. -- - Are you sure we're good? - Always. -- Rory and Lorelai
#! /usr/bin/python from PyQt4 import QtGui ## class Mixin(object): def __init__(self, what): self.what = what def insert(self): print 'inserting', self.what def remove(self): print 'removing', self.what ## class InsertCmd(QtGui.QUndoCommand, Mixin): def __init__(self, what): QtGui.QUndoCommand.__init__(self, 'insert ' + what) Mixin.__init__(self, what) undo = Mixin.remove redo = Mixin.insert class RemoveCmd(QtGui.QUndoCommand, Mixin): def __init__(self, what): QtGui.QUndoCommand.__init__(self, 'remove ' + what) Mixin.__init__(self, what) undo = Mixin.insert redo = Mixin.remove ## undo_stack = QtGui.QUndoStack() insert_cmd = InsertCmd('foo') remove_cmd = RemoveCmd('bar') undo_stack.push(insert_cmd) undo_stack.push(remove_cmd)
_______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt