Undo-Redo, copy instance, custom events and a problem

Discussion in 'Python' started by King, Jul 26, 2010.

  1. King

    King Guest

    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
     
    King, Jul 26, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. black

    undo and redo

    black, Dec 23, 2003, in forum: Python
    Replies:
    0
    Views:
    359
    black
    Dec 23, 2003
  2. black

    undo and redo ?

    black, Jan 2, 2004, in forum: Python
    Replies:
    1
    Views:
    367
    Diez B. Roggisch
    Jan 2, 2004
  3. Robert Brewer

    RE: undo and redo ?

    Robert Brewer, Jan 2, 2004, in forum: Python
    Replies:
    0
    Views:
    366
    Robert Brewer
    Jan 2, 2004
  4. Jason Cavett
    Replies:
    0
    Views:
    325
    Jason Cavett
    Jun 15, 2007
  5. Replies:
    6
    Views:
    485
Loading...

Share This Page