How to open an explorer window?

Mike Driscoll mdriscoll at co.marshall.ia.us
Wed Aug 1 07:11:49 PDT 2007


 

> -----Original Message-----
> From: Robert Dailey [mailto:rcdailey at gmail.com] 
> Sent: Tuesday, July 31, 2007 4:51 PM
> To: wxPython
> Subject: How to open an explorer window?
> 
> Hi,
> 
> I currently use wxPython on windows. Is there a way to make 
> an explorer window open up, displaying the directory that 
> contains a file? For example, if I have the path 
> "C:\myfolder\subfolder\file.txt", I want to pass this path 
> into a function that opens up an explorer window at the 
> folder "C:\myfolder\subfolder\" with the file " file.txt" 
> highlighted. Is this possible? I'm not sure if this is a 
> wxPython ability or if the python libraries support this.
> 
> Thanks.
> 
> 

This probably isn't a wxPython thing. I don't know if you can select a
file, but do open Windows Explorer to a specific directory, all you need
to do is use the subprocess module's Popen method.

subprocess.Popen('explorer c:\\some\\path')

I suppose you could use SendKeys to select a text file, but that's pretty
hackish.

Mike





More information about the wxpython-users mailing list