From: King on 26 Jul 2010 01:32 Hi, I am developing an app using wxPython. The Undo-Redo implementation is based on storing pre & post state of an attribute. You store the instance before changing the value and store the instance after changing the values. While undoing or redoing, you copy/replace the current state with stored once. For color attribute as soon as you choose a color, here is the code: # Custom Event evt = ValueChangeEvent(EVT_COLOR_CHANGED.typeId, self.GetId()) # Store Pre State evt.SetPreState(copy.copy(self.attribute)) # Change the newly selected color self.attribute.setValue(R,G,B) # Store Post State evt.SetPostState(copy.copy(self.attribute)) # Throw Custom Event self.GetEventHandler().ProcessEvent(evt) Both states are copied as new instance with correct values. The problem is when this event is getting fired. evt.GetPreState().GetValue() is showing the post color value. Although GetPreState() & GetPostState() are showing two different instances but I have no idea why values are not coming/stored correctly. Some where in between is messed up and post-state values are copied in pre-state. On a side note, self.attribute.setValue takes three floating values for R,G & B colors but stored them as a text. Similarly self.attribute.getValue() converts text into float and returns. Is there anything related to scope or something? Cheers Prashant
|
Pages: 1 Prev: obtaining pid of child process Next: JBR , RENT TO OWN or BUY WITH NO MONEY DOWN ,050-8320722 |