Thanks Dunn,
The script is working file except the swap option. I am not able to figure out how to access source in “MyDropTarget” class. Secondly if I can
get the source object in “MyDropTarget” class then I don’t think I would be needing customDataObject as I get the color of source easily and do
the either of swap or paste operation.
Prashant
dnd.py (3.13 KB)
···
----- Original Message ----
From: Robin Dunn robin@alldunn.com
To: wxpython-users@lists.wxwidgets.org
Sent: Monday, September 22, 2008 1:50:20 AM
Subject: Re: [wxpython-users] Custom color picker using wx.Panel
Prashant Saxena wrote:
I am trying to create a new color picker using wx.Panel.
Have you seen wx.lib.colourchooser, or
http://xoomer.alice.it/infinity77/main/CubeColourDialog.html
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!
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users