473,770 Members | 5,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1992
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.zmz 5(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
2387
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 to have the number of dialog boxes as files in the directory. I was thinking of using a ActiveX control, but I don't want to make the sure download additional components to be able to do this, so is there maybe some sort of Windows ActiveX control...
6
22451
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 (the back-end, logo, etc...) and save the path. Cheers Nic.
5
21390
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 String) As String ...... End function I seem to be able to get one or the other, but not both Files and Folders. I
17
8029
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: I am trying to use the SaveFileDialog class to get a filename, which is subsequently opened for writing (write access, read sharing, but using read/write sharing doesn't make the problem go away anyway). Sometimes, on the statement where I...
1
15716
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 friend helped me get it working on Acess2002 but i cannot get it to work on Access 2000. Private Sub cmdFileDialog_Click() 'Requires reference to Microsoft Office 10.0 Object Library. Dim fDialog As Office.FileDialog Dim varFile As Variant
3
5219
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 works great. However, once the file dialog becomes visible, if the user clicks on my popup form that exists under the file dialog, the file dialog disappears under the form. Then, when the form clears, the file dialog shows. Select a file, and...
3
2212
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 script to open the txt file and import. Both these scripts seem to work well (ish) but is there a better way of doing this? and is there a way of doing this and only having to run a single script? Copies of the script below. Any help would be much...
1
47484
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 on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
6
26329
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 one table. My problem is I have two buttons I want to use this code for for the two buttons would put the data in different tables. I have tried copying and changing a few things and nothing will work for me. The code is set up in a module and then I...
0
9592
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10231
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8887
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6679
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.