On Fri, 26 Aug 2005 07:52:06 GMT, Wouter van Ooijen (www.voti.nl) <[EMAIL 
PROTECTED]> wrote:

> I have a tool in Python to which I want to add a small GUI. The tools
> currently runs everywhere PySerial is supported. I need a file-access
> dialog. What is the preffered way to to this? Is there a
> platform-independent file-access dialog available, or should I use the
> windows native version when running on windows (and how do I do that)?

Tkinter has a file acces dialog available with the same API on all platforms. 
It is also mapped to the standard dialog on Windows. Since Tkinter is certainly 
installed by default with Python, if a file dialog is everything you need, you 
probably don't have to look further.

To use the dialog, just do:

 from Tkinter import Tk
 from tkFileDialog import askopenfilename
## Tk needs a main window to work, so create one and hide it
root = Tk()
root.withdraw()
## Ask the file name
fileName = askopenfilename(filetypes=[('Python files', '*.py'), ('All files', 
'*')])
if fileName:
   print 'open', fileName
else:
   print 'cancelled'
## Over
root.destroy()

HTH
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in 
'U(17zX(%,5.zmz5(17;8(%,5.Z65\'*9--56l7+-'])"
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to