wxURLDataObject and wxDataObjectComposite

Hi --

I'm trying to get a drop target set up that will accept both a custom format and a URL. The code looks like this:

class MultipleDropTarget(wxPyDropTarget):
     def __init__(self):
         wxPyDropTarget.__init__(self)

         self.list_fmt = wxCustomDataFormat("AGVenueData")
         self.file_fmt = wxDataFormat(wxDF_FILENAME)

         self.create_data_objects()

     def create_data_objects(self):

         ulist_dobj = self.ulist_dobj = wxCustomDataObject(self.list_fmt)
         ulist_dobj.SetData("")
         file_dobj = self.file_dobj = wxFileDataObject()
         url_dobj = self.url_dobj = wxURLDataObject()
         url_dobj.SetURL("")

         both_dobj = wxDataObjectComposite()
         both_dobj.Add(ulist_dobj)
         both_dobj.Add(file_dobj)
         both_dobj.Add(url_dobj)

         self.data = both_dobj
         self.SetDataObject(self.data)

It works fine with the custom data object and file data object, but adding the URL data object gives me this:

Traceback (most recent call last):
   File "blist.py", line 160, in ?
     p = BookmarkListPanel(frame, -1)
   File "blist.py", line 41, in __init__
     self.target = MultipleDropTarget(self.handle_data)
   File "blist.py", line 66, in __init__
     self.create_data_objects()
   File "blist.py", line 79, in create_data_objects
     both_dobj.Add(url_dobj)
   File "C:\Python22\Lib\site-packages\wxPython\clip_dnd.py", line 124, in Add
     val = apply(clip_dndc.wxDataObjectComposite_Add,(self,) + _args, _kwargs)
TypeError: Type error in argument 2 of wxDataObjectComposite_Add. Expected _wxDa
taObjectSimple_p.

Any ideas?

thanks,
--bob

Robert Olson wrote:

Hi --

I'm trying to get a drop target set up that will accept both a custom format and a URL. The code looks like this:

class MultipleDropTarget(wxPyDropTarget):
    def __init__(self):
        wxPyDropTarget.__init__(self)

        self.list_fmt = wxCustomDataFormat("AGVenueData")
        self.file_fmt = wxDataFormat(wxDF_FILENAME)

        self.create_data_objects()

    def create_data_objects(self):

        ulist_dobj = self.ulist_dobj = wxCustomDataObject(self.list_fmt)
        ulist_dobj.SetData("")
        file_dobj = self.file_dobj = wxFileDataObject()
        url_dobj = self.url_dobj = wxURLDataObject()
        url_dobj.SetURL("")

        both_dobj = wxDataObjectComposite()
        both_dobj.Add(ulist_dobj)
        both_dobj.Add(file_dobj)
        both_dobj.Add(url_dobj)

        self.data = both_dobj
        self.SetDataObject(self.data)

It works fine with the custom data object and file data object, but adding the URL data object gives me this:

Traceback (most recent call last):
  File "blist.py", line 160, in ?
    p = BookmarkListPanel(frame, -1)
  File "blist.py", line 41, in __init__
    self.target = MultipleDropTarget(self.handle_data)
  File "blist.py", line 66, in __init__
    self.create_data_objects()
  File "blist.py", line 79, in create_data_objects
    both_dobj.Add(url_dobj)
  File "C:\Python22\Lib\site-packages\wxPython\clip_dnd.py", line 124, in Add
    val = apply(clip_dndc.wxDataObjectComposite_Add,(self,) + _args, _kwargs)
TypeError: Type error in argument 2 of wxDataObjectComposite_Add. Expected _wxDa
taObjectSimple_p.

Any ideas?

IIRC, the wxURLDataObject is already a composite...

···

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

TypeError: Type error in argument 2 of wxDataObjectComposite_Add. Expected _wxDa
taObjectSimple_p.

Well, I figured some of this out. wxURLDataObject is a composite itself, of a text dataobj and a custom dataobj of type CFSTR_SHELLURL, which is defined in the C++ code as _T("UniformResourceLocator"). If I create a custom data object of type "UniformResourceLocator" it still doesn't accept URLs. I'm wondering if the type needs to be a unicode string (I don't think I'm using a unicode python).

So what I think would be necessary is the exporting of a simple data object of type CFSTR_SHELLURL, as well possibly as composite of that and text..

--bob