473,387 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

file access dialog

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
4 1975
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
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
For simple, it's hard to beat EasyGUI: http://www.ferg.org/easygui/

Bob

Aug 26 '05 #4
>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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: yanivoliver | last post by:
Hey, I'm currently trying to find a way to open a dialog box that will allow me to select more than one file at a time, so if I want to upload select all the files in a directory, I won't have...
6
by: WindAndWaves | last post by:
Hi guys Thank you for all your previous answers. My new question is as follows: how do I create a folder/file browser in access 2003. That is, I would like the user to locate several files...
5
by: Phil Stanton | last post by:
Can anyone let me have the code for opening the open file dialog box and getting either a file or folder name as the output. I suspect it will look like Function GetPathOrFile(InputPath as...
17
by: Peter Duniho | last post by:
I searched using Google, on the web and in the newsgroups, and found nothing on this topic. Hopefully that means I just don't understand what I'm supposed to be doing here. :) The problem: ...
1
by: Josha | last post by:
I am very new to vb and Access and the like, please be gentle. I am trying to use the below script in Access 2000 to open a file picker dialog then display the selected text in a text box. A...
3
by: ApexData | last post by:
I am using code from the following links to establish a Browse File and Browse Folder dialog. http://www.mvps.org/access/api/api0001.htm http://www.mvps.org/access/api/api0002.htm This code...
3
by: derfer | last post by:
I am trying to import a .inf file into access (the file comes from the output of some 3rd party software). I have managed to convert the file by opeing it in notepad and re-saving then a seperate...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
6
by: provor | last post by:
Hello, I have the following code that I am using when a user presses a button to import an excel file into a table. The code is hard coded to point to the correct table. This works great for this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.