Filedrop not working everywhere

222 views
Skip to first unread message

nick26

unread,
Jun 4, 2012, 7:08:35 AM6/4/12
to wxPython-users
Hello all!

I'm developing an application where currently connected machines are
displayed as images and files dropped on the image are then sent to
the target machine. However I'm having problem with the filedropping.
I have looked through several different tutorials/examples and
modifying the Filedrop class isn't helping at all, when files are
dragged on to the app, "stop sign" is shown.

However, when compiled with py2exe to be run on machines which are not
in frequent use, file drop works, which makes me wonder, if this some
windows update/software issue. These machines have only few
application installed like office and acrobat, as they are to be used
in conferences... They are installed from the same windows image as my
developing machine.

I'm running wxpython 2.9.3 and python 2.7.2 on Windows 7 (64bit).
Reduced example app (based on http://zetcode.com/wxpython/draganddrop/):
import wx

class FileDrop(wx.FileDropTarget):
def __init__(self,window):
wx.FileDropTarget.__init__(self)
self.window = window
def OnDropFiles(self, x, y, filenames):
print "Dropped files:"
for name in filenames:
print name +","
print "\n"
class DropFile(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size = (450, 400))
self.screens = wx.BoxSizer(wx.HORIZONTAL)
self.panel = wx.Panel(self,-1)
self.panel.SetBackgroundColour(wx.WHITE)
i = 0
while i<3:
tra =
wx.Image("generated_image.png",wx.BITMAP_TYPE_PNG).ConvertToBitmap()
img = wx.StaticBitmap(parent=self.panel, id=i, bitmap=tra)
dt = FileDrop(img)
img.SetDropTarget(dt)
self.screens.Add(img,0, wx.LEFT|wx.RIGHT, border=3)
i += 1
self.screens.Layout()
self.panel.SetSizer(self.screens)
self.Show(True)

app = wx.App()
DropFile(None, -1, 'Filedrop')
app.MainLoop()

Robin Dunn

unread,
Jun 4, 2012, 1:16:25 PM6/4/12
to wxpytho...@googlegroups.com
On 6/4/12 4:08 AM, nick26 wrote:
> Hello all!
>
> I'm developing an application where currently connected machines are
> displayed as images and files dropped on the image are then sent to
> the target machine. However I'm having problem with the filedropping.
> I have looked through several different tutorials/examples and
> modifying the Filedrop class isn't helping at all, when files are
> dragged on to the app, "stop sign" is shown.
>
> However, when compiled with py2exe to be run on machines which are not
> in frequent use, file drop works, which makes me wonder, if this some
> windows update/software issue. These machines have only few
> application installed like office and acrobat, as they are to be used
> in conferences... They are installed from the same windows image as my
> developing machine.
>
> I'm running wxpython 2.9.3 and python 2.7.2 on Windows 7 (64bit).


It may be due to using wx.StaticBitmap as the window handling the drop,
and the fact that some machines may have different versions of the
system common controls DLL. If any native widgets are not able to
handle being a drop target then I would guess that it would be "static"
ones.

Try using the generic static bitmap class in wx.lib.statbmp instead.


--
Robin Dunn
Software Craftsman
http://wxPython.org

nick26

unread,
Jun 5, 2012, 4:42:29 AM6/5/12
to wxPython-users
I tried using Generic Bitmap and I tried using different versions of
wxpython(2.8.12.1 (msw-ansi),2.8.12.1 (msw-unicode),2.9.3.1 msw
(classic)) to no avail. Funny thing is that the DnD demo in wxpython
demos is working.. I'll try to go over that code and compare.
Message has been deleted

nick26

unread,
Jun 5, 2012, 8:02:36 AM6/5/12
to wxPython-users
Update on the matter: it seems that disabling UAC is the key here. As
I was running my app and sample app with admin privileges (I have a
context menu shortcut for cmd as admin), the system would not allow
drag and drop from medium-privileged explorer to higher privileged
app.
Related links:
http://blogs.msdn.com/b/patricka/archive/2010/01/28/q-why-doesn-t-drag-and-drop-work-when-my-application-is-running-elevated-a-mandatory-integrity-control-and-uipi.aspx
http://helgeklein.com/blog/2010/03/how-to-enable-drag-and-drop-for-an-elevated-mfc-application-on-vistawindows-7/

Hopefully this helps someone in the future :)
Reply all
Reply to author
Forward
0 new messages