DragAndDrop

Hi all,

does anybody know, why this does small example does not work?

regards,

Thorsten Henninger

from wxPython.wx import *
class MainWindow(wxFrame):
   def __init__(self,parent):
      wxFrame.__init__(self,parent,-1, "")
      target = wxDropTarget(None)
      self.SetDropTarget(target)
       
class MyApp(wxApp):
   def OnInit(self):
      frame = MainWindow(None)
      return true
        app = MyApp(0)
app.MainLoop()

Traceback (most recent call last):
  File "dragdrop.py", line 15, in ?
    app = MyApp(0)
  File "/usr/lib/python2.2/site-packages/wxPython/wx.py", line 1802, in __init__
    _wxStart(self.OnInit)
  File "dragdrop.py", line 12, in OnInit
    frame = MainWindow(None)
  File "dragdrop.py", line 7, in __init__
    self.SetDropTarget(target)
  File "/usr/lib/python2.2/site-packages/wxPython/windows.py", line 556, in SetDropTarget
    val = apply(windowsc.wxWindow_SetDropTarget,(self,) + _args, _kwargs)
TypeError: Type error in argument 2 of wxWindow_SetDropTarget. Expected _wxDropTarget_p.

target = wxDropTarget(None)

···

==
target = wxDropTarget(self)

I think.

Quoting Thorsten Henninger <henni@brainbot.com>:

Hi all,

does anybody know, why this does small example does not work?

regards,

Thorsten Henninger

from wxPython.wx import *

class MainWindow(wxFrame):
   def __init__(self,parent):
      wxFrame.__init__(self,parent,-1, "")
      target = wxDropTarget(None)
      self.SetDropTarget(target)
       
class MyApp(wxApp):
   def OnInit(self):
      frame = MainWindow(None)
      return true
        
app = MyApp(0)
app.MainLoop()

Traceback (most recent call last):
  File "dragdrop.py", line 15, in ?
    app = MyApp(0)
  File "/usr/lib/python2.2/site-packages/wxPython/wx.py", line 1802,
in
__init__
    _wxStart(self.OnInit)
  File "dragdrop.py", line 12, in OnInit
    frame = MainWindow(None)
  File "dragdrop.py", line 7, in __init__
    self.SetDropTarget(target)
  File "/usr/lib/python2.2/site-packages/wxPython/windows.py", line
556,
in SetDropTarget
    val = apply(windowsc.wxWindow_SetDropTarget,(self,) + _args,
_kwargs)
TypeError: Type error in argument 2 of wxWindow_SetDropTarget.
Expected
_wxDropTarget_p.

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

Thorsten Henninger wrote:

from wxPython.wx import *

class MainWindow(wxFrame):
  def __init__(self,parent):
     wxFrame.__init__(self,parent,-1, "")
     target = wxDropTarget(None)
     self.SetDropTarget(target)
     class MyApp(wxApp):
  def OnInit(self):
     frame = MainWindow(None)
     return true
       app = MyApp(0)
app.MainLoop()

Traceback (most recent call last):
File "dragdrop.py", line 15, in ?
   app = MyApp(0)
File "/usr/lib/python2.2/site-packages/wxPython/wx.py", line 1802, in __init__
   _wxStart(self.OnInit)
File "dragdrop.py", line 12, in OnInit
   frame = MainWindow(None)
File "dragdrop.py", line 7, in __init__
   self.SetDropTarget(target)
File "/usr/lib/python2.2/site-packages/wxPython/windows.py", line 556, in SetDropTarget
   val = apply(windowsc.wxWindow_SetDropTarget,(self,) + _args, _kwargs)
TypeError: Type error in argument 2 of wxWindow_SetDropTarget. Expected _wxDropTarget_p.

I'm not sure yet why it is behaving this way, (there should be a better exception...) but you either need to use one of the other ready made drop target classes, or use wxPyDropTarget if you need a custom one.

···

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