Using win32ui.CreateFileDialog() to get the name of a file.
steve at holdenweb.com
Sat Nov 19 18:59:07 CET 2005
Joey C. wrote:
> I'm writing a program that creates a series of batch operations to
> convert movies to be used on iPodLinux. The programs that do the
> encoding and conversions are seperate from mine and all mine does is
> use os.system() to call the program.
> However, it needs to get an input file and an output file. Originally
> I was using just raw input, but I got adventuresome and decided to try
> win32ui.CreateFileDialog(). But this will only open or save a file and
> its output will be either 1 or a failure. How might I go about using
> it to get the _file name_ of a file.
> For example.
> Box appears asking user to find a file they want. They double click on
> the file. Let's call it C:\Video.avi
> Then another dialog box appears asking them where to save it. They
> save it at C:\iPodVideo.avi.
> Now the Python program extracts the name of these files and then uses
> os.system() to run:
> mencoder.exe -[parameters] C:\Video.avi -o C:\iPodVideo.avi
> Note that I'm not actually inputting the contents of the file, I'm just
> passing the file name along.
> How might I do this? Thanks.
After you've had the user interact with the dialog you should call its
GetFileName() method. The interactive interpreter can be useful in
finding things like this out (though many details of objects can remain
hidden in the Windows environment):
['GetFileExt', 'GetFileName', 'GetFileTitle', 'GetPathName',
'GetPathNames', 'GetReadOnlyPref', 'SetOFNInitialDir', 'SetOFNTitle']
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/
More information about the Python-list