Hello, guys!
I'm having a trouble with Drag'n'Drop.
well, here is the fragment of my code:
if obj.selected:
for i in self.app.select_list:
dr_list.append(i.id)
dr_text=cPickle.dumps(dr_list)
else:
dr_text=cPickle.dumps([obj.id])
data=wxTextDataObject(dr_text)
dropsource=wxDropSource(self)
dropsource.SetData(data)
result=dropsource.DoDragDrop()
... ... ... ...
class VerbaDropTarget(wxPyDropTarget):
def __init__(self,branch,parent):
wxPyDropTarget.__init__(self)
self.data=wxTextDataObject()
self.SetDataObject(self.data)
and the problem itself is the following:
under MSW whatever i do, wherever i drag the object, "Mr. Gates says No!" I
mean the icon near the mouse pointer is always saying, that the object cannot
be dropped here... The interesting point in this is that under GTK (with Python 2.1) everything works fine. (Python used with MSW is 2.2.1)
What did i do wrong? At least can anyone explain in what cases the "reject"
icon appears? (I mean what could be the reason of rejection)
Please help me! I'm completely exhausted and want to sleep... But this bug
is like a splinter, that i cannot pull out of my mind for very long time
Thanks in advance!
···
--
-----------------------------------------------------------------
ICQ#73297983 Your sincerely, Maxx. mailto:maxxua@pisem.net
if obj.selected:
for i in self.app.select_list:
dr_list.append(i.id)
dr_text=cPickle.dumps(dr_list)
else:
dr_text=cPickle.dumps([obj.id])
data=wxTextDataObject(dr_text)
dropsource=wxDropSource(self)
dropsource.SetData(data)
result=dropsource.DoDragDrop()
... ... ... ...
class VerbaDropTarget(wxPyDropTarget):
def __init__(self,branch,parent):
wxPyDropTarget.__init__(self)
self.data=wxTextDataObject()
self.SetDataObject(self.data)
and the problem itself is the following:
under MSW whatever i do, wherever i drag the object, "Mr. Gates says No!"
I
mean the icon near the mouse pointer is always saying, that the object
cannot
be dropped here...
I think you may need the OnDragOver method as well. Take a look at the
CustomDragDrop.py module in the demo and compare what it with yours and see
what's different.
···
--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython!
Hello again!
I've added wxDropTarget::OnDragOver() function to my drop droptarget
implementation:
Well, here is the fragment of my code:
# Pickling a simple list, and making a text from it:
if obj.selected:
for i in self.app.select_list:
dr_list.append(i.id)
dr_text=cPickle.dumps(dr_list)
else:
dr_text=cPickle.dumps([obj.id])
# Starting Drag'n'Drop
data=wxTextDataObject(dr_text)
dropsource=wxDropSource(self)
dropsource.SetData(data)
result=dropsource.DoDragDrop()
... ... ... ...
class VerbaDropTarget(wxPyDropTarget):
def __init__(self,branch,parent):
wxPyDropTarget.__init__(self)
self.data=wxTextDataObject()
self.SetDataObject(self.data)
and the problem itself is the following:
under MSW whatever i do, wherever i drag the object, "Mr. Gates says No!" I
mean the icon near the mouse pointer is always saying, that the object cannot
be dropped here... The interesting point in this is that under GTK (with Python 2.1) everything works fine. (Python used with MSW is 2.2.1)
What did i do wrong? At least can anyone explain in what cases the "reject"
icon appears? (I mean what could be the reason of rejection)
After adding this functions i found out that the wxDropTarget::OnDrop()
function not even been called!!! While the des_res argument in
wxDropTarget::OnDragOver() function was wxDragMove. (Despite of this fact, the
icon near the mouse was still saying 'No')
What am i doing wrong?
Thanks in advance!
···
--
-----------------------------------------------------------------
ICQ#73297983 Your sincerely, Maxx. mailto:maxxua@pisem.net
This may be insultingly basic (like asking: "Did you plug in the
appliance?") but do you bind the drop target to a window anywhere by
calling its
SomeWindow.SetDropTarget(YourDropTargetInstance)
method properly? Also note that the method takes an instance of the
class as a parameter, _not_ the class itself, although I would presume
you'd get some error message if you tried that.
After adding this functions i found out that the wxDropTarget::OnDrop()
function not even been called!!! While the des_res argument in
wxDropTarget::OnDragOver() function was wxDragMove. (Despite of this fact,
the
icon near the mouse was still saying 'No')
What am i doing wrong?
Without seeing all of your code (preferably a just small sample that shows
the problem) all I can say is take a close look at the demo and figure out
what you are doing differently.
···
--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython!
Yes, i did. The point is that everything goes fine till the turn of OnDrop.
I mean, the OnEnter, OnLeave, OnDragOver etc. functions are called at the
proper time with, and all of them are working perfect. OnDragOver returns
something like wxDragMove. But when i releise the mouse ... Ooops! And nothing
happens! The OnDrop is not called. In documentation i failed to fine the answer
to the question "In what cases OnDrop is not called?" That is why i'm asking.
Thanks, anyway!
···
On Fri, 7 Jun 2002, Robert Amesz wrote:
This may be insultingly basic (like asking: "Did you plug in the
appliance?") but do you bind the drop target to a window anywhere by
calling its
SomeWindow.SetDropTarget(YourDropTargetInstance)
method properly? Also note that the method takes an instance of the
class as a parameter, _not_ the class itself, although I would presume
you'd get some error message if you tried that.
--
-----------------------------------------------------------------
ICQ#73297983 Your sincerely, Maxx. mailto:maxxua@pisem.net
In documentation i failed to fine the answer to the question "In
what cases OnDrop is not called?" That is why i'm asking.
My guess (and it's just a guess) would be: when the data types is not
acceptable to the drop target. The fact that you can't 'persuade' the
drop target to show a proper icon while dragging might be a significant
clue here. A wxTextDataObject is commonly used for clipboard and text
DnD operations, it might just be (possibly due to the Python wrapper)
that a general drop target is no good for that. What happens if you
drag ordinary text onto your target? And what happens if you derive
your drop target from a wxTextDropTarget instead? Answers to these
questions may provide some insights.
Ultimately I think you should make your own specialized data object, as
the "Custom DnD" demo does[*]. After all, a pickled Python object is
hardly the same as ordinary text. Your liable to get some strange
results if you drag text from your editor onto the drop target.
Robert Amesz
···
--
[*] Repeat after me "The wxPython demo is your friend, copy & paste are
your faithful servants."
> In documentation i failed to fine the answer to the question "In
> what cases OnDrop is not called?" That is why i'm asking.
My guess (and it's just a guess) would be: when the data types is not
acceptable to the drop target. The fact that you can't 'persuade' the
drop target to show a proper icon while dragging might be a significant
clue here. A wxTextDataObject is commonly used for clipboard and text
DnD operations, it might just be (possibly due to the Python wrapper)
that a general drop target is no good for that. What happens if you
drag ordinary text onto your target? And what happens if you derive
your drop target from a wxTextDropTarget instead? Answers to these
questions may provide some insights.
Ultimately I think you should make your own specialized data object, as
the "Custom DnD" demo does[*]. After all, a pickled Python object is
hardly the same as ordinary text. Your liable to get some strange
results if you drag text from your editor onto the drop target.
The thing that looked like a bug of MSW, finally turned out to be a bug of
GTK i guess. Because I simply missed "true" argument for DoDragDrop(), which
will reject moving, as it was under MSW (I still don't know why there was no
reaction on my pressing Ctrl ...) But under GTK "move", was still allowed
despite of the false default argument of DoDragDrop(). GTK vs MSW GTK is
seems to be still loosing :)))
···
--
-----------------------------------------------------------------
ICQ#73297983 Your sincerely, Maxx. mailto:maxxua@pisem.net