FileDropTarget TypeError in Phoenix

Hi,

I am getting a TypeError when I drag and drop files onto a widget in wxPython Phoenix, but only to stdout. It doesn’t actually cause the script to stop. Here’s the error:

builtins.TypeError: invalid result from MyFileDropTarget.OnDropFiles(), an integer is required (got type NoneType)

My code is here: https://gist.github.com/driscollis/a71018bc138a4c1974bca90e30d9f0e4

This code worked fine in wxPython 3.0 Classic. Interestingly the code works as expected other than the odd output that goes to stdout.

Does anyone know why this is happening? I am running Phoenix on Windows 7 with Python 3.5.

Thanks,

Mike

···

Mike Driscoll

Blog: http://blog.pythonlibrary.org

Books: Python 101, Python 201: Intermediate Python

Interestingly, I get pretty much the same error with a TextDropTarget as well. PyDropTarget’s work fine for me though.

Mike

···

On Sunday, November 27, 2016 at 2:06:53 PM UTC-6, mike wrote:

Hi,

I am getting a TypeError when I drag and drop files onto a widget in wxPython Phoenix, but only to stdout. It doesn’t actually cause the script to stop. Here’s the error:

My code is here: https://gist.github.com/driscollis/a71018bc138a4c1974bca90e30d9f0e4

This code worked fine in wxPython 3.0 Classic. Interestingly the code works as expected other than the odd output that goes to stdout.

Does anyone know why this is happening? I am running Phoenix on Windows 7 with Python 3.5.

Thanks,

Mike

builtins.TypeError: invalid result from MyFileDropTarget.OnDropFiles(), an integer is required (got type NoneType)

I think it's probably complaining because you're not returning a bool in OnDropFiles.

Scott

···

On Sun, 27 Nov 2016, Mike Driscoll wrote:

Hi,

I am getting a TypeError when I drag and drop files onto a widget in
wxPython Phoenix, but only to stdout. It doesn't actually cause the script
to stop. Here's the error:

builtins.TypeError: invalid result from MyFileDropTarget.OnDropFiles(), an
integer is required (got type NoneType)
My code is
here: drop_file_target.py · GitHub

This code worked fine in wxPython 3.0 Classic. Interestingly the code works
as expected other than the odd output that goes to stdout.

Does anyone know why this is happening? I am running Phoenix on Windows 7
with Python 3.5.

That does seem to be the issue. Do you know if that is documented somewhere?

Thanks,
Mike

···

On Sunday, November 27, 2016 at 5:28:04 PM UTC-6, Scott Talbert wrote:

On Sun, 27 Nov 2016, Mike Driscoll wrote:

Hi,

I am getting a TypeError when I drag and drop files onto a widget in

wxPython Phoenix, but only to stdout. It doesn’t actually cause the script

to stop. Here’s the error:

builtins.TypeError: invalid result from MyFileDropTarget.OnDropFiles(), an

integer is required (got type NoneType)

My code is

here: https://gist.github.com/driscollis/a71018bc138a4c1974bca90e30d9f0e4

This code worked fine in wxPython 3.0 Classic. Interestingly the code works

as expected other than the odd output that goes to stdout.

Does anyone know why this is happening? I am running Phoenix on Windows 7

with Python 3.5.

I think it’s probably complaining because you’re not returning a bool in
OnDropFiles.

Scott

The wxWidgets documentation mentions it:
http://docs.wxwidgets.org/3.1/classwx_file_drop_target.html

The Phoenix version could probably be a bit more informative:
https://wxpython.org/Phoenix/docs/html/wx.FileDropTarget.html

···

On Mon, 28 Nov 2016, Mike Driscoll wrote:

On Sunday, November 27, 2016 at 5:28:04 PM UTC-6, Scott Talbert wrote:
      On Sun, 27 Nov 2016, Mike Driscoll wrote:

      > Hi,
      >
      > I am getting a TypeError when I drag and drop files onto a
      widget in
      > wxPython Phoenix, but only to stdout. It doesn't actually
      cause the script
      > to stop. Here's the error:
      >
      > builtins.TypeError: invalid result from
      MyFileDropTarget.OnDropFiles(), an
      > integer is required (got type NoneType)
      > My code is
      >
      here: drop_file_target.py · GitHub
      >
      > This code worked fine in wxPython 3.0 Classic. Interestingly
      the code works
      > as expected other than the odd output that goes to stdout.
      >
      > Does anyone know why this is happening? I am running Phoenix
      on Windows 7
      > with Python 3.5.

      I think it's probably complaining because you're not returning a
      bool in
      OnDropFiles.

      Scott

That does seem to be the issue. Do you know if that is documented somewhere?

I missed that somehow. Thanks for taking the time to find that.

Mike

···

On Mon, Nov 28, 2016 at 10:27 AM, Scott Talbert <swt@techie.net> wrote:

On Mon, 28 Nov 2016, Mike Driscoll wrote:

On Sunday, November 27, 2016 at 5:28:04 PM UTC-6, Scott Talbert wrote:

      On Sun, 27 Nov 2016, Mike Driscoll wrote:

      > Hi,
      >
      > I am getting a TypeError when I drag and drop files onto a
      widget in
      > wxPython Phoenix, but only to stdout. It doesn't actually
      cause the script
      > to stop. Here's the error:
      >
      > builtins.TypeError: invalid result from
      MyFileDropTarget.OnDropFiles(), an
      > integer is required (got type NoneType)
      > My code is
      >
      here: https://gist.github.com/driscollis/a71018bc138a4c1974b
ca90e30d9f0e4
      >
      > This code worked fine in wxPython 3.0 Classic. Interestingly
      the code works
      > as expected other than the odd output that goes to stdout.
      >
      > Does anyone know why this is happening? I am running Phoenix
      on Windows 7
      > with Python 3.5.

      I think it's probably complaining because you're not returning a
      bool in
      OnDropFiles.

      Scott

That does seem to be the issue. Do you know if that is documented
somewhere?

The wxWidgets documentation mentions it:
wxWidgets: wxFileDropTarget Class Reference

The Phoenix version could probably be a bit more informative:
wx.FileDropTarget — wxPython Phoenix 4.2.3a1 documentation

-----------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org
Books: Python 101 <https://gum.co/py101&gt;, Python 201: Intermediate Python
<https://gum.co/py201&gt;