Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8987059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:41:59+00:00 2026-06-15T21:41:59+00:00

I have a ListCtrl containing some items representing (huge and remote) files. I’d like

  • 0

I have a ListCtrl containing some items representing (huge and remote) files. I’d like the user to be able to drag an item to an open directory window and thereby create a file (really initiating a download). I’d like my application to get a message like “the user dragged your list item to this path”, so that I can then proceed and write the file data to that location.

I know how to do something similar if the source file is available on the local file system, but my files are large and on a remote system, (think FTP client) so I cannot speculatively copy them to disk in case the user wants to drag’n’drop them later.

How can I accomplish this using wxpython? Is it even possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:42:01+00:00Added an answer on June 15, 2026 at 9:42 pm

    I searched the web pretty hard but could not find a way to do this either. Even Robin Dunn says that the drop source app knows nothing about the target when data is dropped into the file system. But I figured out an easy way to do it, at least on Windows. We simply drag a DropSource containing an empty FileDataObject onto an Explorer window. Since there’s no data, all this does is bring the Explorer window to the top, which allows us to get the path to the folder the user dragged into. First, be sure to bind the event to the ListCtrl up in the __init__ def of the ListCtrl’s parent:

    self.lc.Bind(wx.EVT_LIST_BEGIN_DRAG, self.onDrag)
    

    Then do this in the method called by the event:

    def onDrag(self, event):
        data = wx.FileDataObject()
        obj = event.GetEventObject()
        dropSource = wx.DropSource(obj)
    
        dropSource.SetData(data)
    
        #next line will make the drop target window come to top, allowing us
        #to get the info we need to do the work, if it's Explorer
        result = dropSource.DoDragDrop(0)
    
        #get foreground window hwnd
        h = win32gui.GetForegroundWindow()
    
        #get explorer location
        s = win32com.client.Dispatch("Shell.Application")
        loc, outdir = None, None
        for w in s.Windows():
            if int(w.Hwnd) == h:
                loc = w.LocationURL
        if loc:
            outdir = loc.split('///')[1]
            outdir = urllib.unquote(outdir)
    
        #got what we need, now download to outfol
        if outdir and os.path.isdir(outdir):
            self.dloadItems(event, outdir)
    
    
        return
    

    The dloadItems method gets the selected items from the ListCtrl and then (in this app) downloads the items from a REST server to the outdir.

    This solution requires the pywin32 extensions, of course.

    good luck,

    Mike

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListCtrl that displays a list of items for the user to
I have three columns in my wx.ListCtrl(size=(-1,200)) . I would like the columns to
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
I have a Javascript object that (very simplified) looks like this if('undefined' !== typeof(listCtrls)){
Have I in some way delete this Task or it is self-destroyed? Task.Factory.StartNew(() =>
Have created a ATL COM project through which I am inserting Menu Items to
I have created an appliation in wxpython and I have a simple ListCtrl and
Have some validating problems which seem to appear only when using the Auth component.
Have just got a surprise and would appreciate some suggestions. The simple query below
I have a listctrl with CheckBox in it(LVS_EX_CHECKBOXES) .It is a single column List

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.