By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,480 Members | 767 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,480 IT Pros & Developers. It's quick & easy.

file access dialog

P: n/a
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)?
Wouter van Ooijen

-- ------------------------------------
http://www.voti.nl
Webshop for PICs and other electronics
http://www.voti.nl/hvu
Teacher electronics and informatics
Aug 26 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Fri, 26 Aug 2005 07:52:06 GMT, Wouter van Ooijen (www.voti.nl) <wo****@voti.nl> 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+-'])"
Aug 26 '05 #2

P: n/a
Wouter van Ooijen 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)?


depends on what GUI toolkit you prefer to use.

for Tkinter (which is available on most modern platforms), see "File
Dialogs" on this page:

http://www.pythonware.com/library/tk...data-entry.htm

the following thread may also be helpful:

http://tinyurl.com/b2zxb

</F>

Aug 26 '05 #3

P: n/a
For simple, it's hard to beat EasyGUI: http://www.ferg.org/easygui/

Bob

Aug 26 '05 #4

P: n/a
>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.


Great :)
Wouter van Ooijen

-- ------------------------------------
http://www.voti.nl
Webshop for PICs and other electronics
http://www.voti.nl/hvu
Teacher electronics and informatics
Aug 26 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.