OnDragOver problems

Hi all,

   sorry if this is a repost, but it seems that my original e-mail has
been filtered out.

I am trying to implement some DnD from a treectrl to a flatnotebook.
Everything works fine, except the implementation of OnDragOver inside
a DropTarget class.
Basically, if the dragged tree item has no associated data (empty
dictionary), I would like to have the same "barred" icon which
provides a visual feedback to the user (the dop can't be performed
because there is no data).

This is what I do:

class DropTarget(wx.DropTarget):

   def __init__(self, parent):
       """ Default class constructor. """

       wx.DropTarget.__init__(self)

       self._parent = parent
       self._dataobject =
wx.CustomDataObject(wx.CustomDataFormat("SymphonyPlot"))
       self.SetDataObject(self._dataobject)

   def OnDragOver(self, x, y, dragres):

       if not self.GetData():
           return wx.DragNone

       draginfo = self._dataobject.GetData()
       drginfo = cPickle.loads(draginfo)

       if not drginfo.GetPlotData():
           return wx.DragNone

       return dragres

   def OnData(self, x, y, dragres):
       """ Handles the OnData() method to call the real DnD routine. """

       if not self.GetData():
           return wx.DragNone

       draginfo = self._dataobject.GetData()
       drginfo = cPickle.loads(draginfo)

       if not drginfo.GetPlotData():
           return wx.DragNone

       return self._parent.OnDropTarget(x, y, drginfo.GetPlotData())

Well, I am surely doing something stupid here, but as soon as
OnDragOver is called, Python crashes with the usual Windows error
message box. The offending line in OnDragOver is:

       if not self.GetData():
           return wx.DragNone

Does anyone know what I may be doing wrong?

Thank you for every hint.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/

Yeah, you can't call self.GetData() during the DragOver, you can only do
it when the data is dropped. It seems to me that your dragover method
is testing to see that 1) it can get data and 2) the data it gets isn't
an empty plot. Do the 'is data empty' test on the drag out (not
starting up dragging if it doesn't have any data to drag), and don't
bother with the 'can it get the data' test.

- Josiah

···

"Andrea Gavana" <andrea.gavana@gmail.com> wrote:

   def OnDragOver(self, x, y, dragres):

       if not self.GetData():
           return wx.DragNone

Well, I am surely doing something stupid here, but as soon as
OnDragOver is called, Python crashes with the usual Windows error
message box. The offending line in OnDragOver is:

       if not self.GetData():
           return wx.DragNone

Does anyone know what I may be doing wrong?

Hello

I be a litle bit confused because that…

wxApp::OnRun

virtual int OnRun()

This virtual function is where the execution of a program
written in wxWidgets starts. The default implementation just
enters the main loop and starts handling the events until it
terminates, either because ExitMainLoop
has been explicitly called or because the last frame has been deleted
and GetExitOnFrameDelete
flag is true (this is the default).

The return value of this function becomes the exit code of the
program, so it should return 0 in case of successful termination.

my wxApp object haven’t got a wx.App.OnRun methode???

When I write my owen OnRun function, it will not call it!!

What did I wrong?

class EasyFinanzManager(wx.App):

def __init__(self):

    wx.App.__init__(self)



def OnInit(self):

    sys.stdout = output.stdout()

    sys.stderr = output.stderr()

    frame = MainFrame(None)

    frame.Show()

    self.SetTopWindow(frame)

    print 'Anwendung gestartet'

    return True

   

def OnRun(self):

    try:

        wx.App.OnRun()

        return 0

    except Exception, ex:

        sys.stderr.write(ex)

        return -1



def OnExceptionInMainLoop():

    print "Error"

Greeze Micha

Micha Reiser wrote:

my wxApp object haven't got a wx.App.OnRun methode???

When I write my owen OnRun function, it will not call it!!

OnRun is called by the framework for C++ apps, but because of they way that things are done for Python I couldn't use that same model. Instead just call MainLoop yourself.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hello

I added the Methode, because I try to catch all exception, which happens
during the MainLoop() (after the programm was start).

···

-----Ursprüngliche Nachricht-----
Von: Robin Dunn [mailto:robin@alldunn.com]
Gesendet: Mittwoch, 25. Oktober 2006 00:18
An: wxPython-users@lists.wxwidgets.org
Betreff: Re: [wxPython-users] OnDragOver problems

Micha Reiser wrote:

my wxApp object haven't got a wx.App.OnRun methode???

When I write my owen OnRun function, it will not call it!!

OnRun is called by the framework for C++ apps, but because of they way
that things are done for Python I couldn't use that same model. Instead
just call MainLoop yourself.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org