I am trying to create a new color picker using wx.Panel. I need to add DragNDrop functionality to this panle in such a way that all the instances of this panel
should be able to swap/replace back ground color when dragging from source to target. AFAIK you always need to setup a relationship between source and target to establish DnD behavior. In my case I am thinking to create a class variable of list type that store every instance of this panel when it’s being created and when ever you create a new instance, loop through entire list and setup DnD behavior between all the instances that has been created with this new one.
Do you think this is the right approach? I need some guide lines over here.
I need to add DragNDrop functionality to this panle in such a way that all the instances of this panel
should be able to swap/replace back ground color when dragging from source to target. AFAIK you always need to setup a relationship between source and target to establish DnD behavior. In my case I am thinking to create a class variable of list type that store every instance of this panel when it's being created and when ever you create a new instance, loop through entire list and setup DnD behavior between all the instances that has been created with this new one.
Do you think this is the right approach? I need some guide lines over here.
I'm not sure I understand. Do you want all color pickers to be changed when you drag a new item to one of them? If so then keeping a list of them and iterating over it is one way to do it. Another would be to use pubsub and simply publish a message when the change happens. Then whatever is subscribed to that message (like all the pickers) can simply update themselves when they receive the message.
On the other hand, if you are just looking for how to communicate data between the source and the target, then all you need to do is define a custom data format and use that for the DnD. There is an example of this in the demo that sends a list of line segments from the source to the target.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!