Hello,
i have a program in which i plot 10 subplots with matplotlib. To launch the program i now type in the console:
python dataplot.py DATAFILE_10.10.07.csv
However what i want is that python asks me for a file which i can then select in a sort of browse window. How to implement this?
I though of creating a GUI with Qt in which you browse (which i dont know how to do) and then click on the button PLOT which should launch the program dataplot with the datafile that has ben selected.
Hope someone can help me.
3 7089
Hello,
i have a program in which i plot 10 subplots with matplotlib. To launch the program i now type in the console:
python dataplot.py DATAFILE_10.10.07.csv
However what i want is that python asks me for a file which i can then select in a sort of browse window. How to implement this?
I though of creating a GUI with Qt in which you browse (which i dont know how to do) and then click on the button PLOT which should launch the program dataplot with the datafile that has ben selected.
Hope someone can help me.
It's pretty simple using Tkinter. There's even a way to hide the Tk main window (I think): - from Tkinter import Tk
-
from tkFileDialog import askopenfilename
-
-
-
if __name__ == '__main__':
-
root=Tk()
-
fileName = askopenfilename()
-
root.destroy()
-
print fileName
-
When working in windows, I use the code that I have pasted below. At one time I looked at all the interesting things you could do with this simple example, but have just been copying, pasting, and making minor mods for years. I have to say though that within win32 it is about as simple and straight forward as I could find. - >>> import win32ui,win32con
-
>>> fd = win32ui.CreateFileDialog(1,'','', 0,'Text |*.txt')
-
>>> fd.SetOFNTitle("Select Text File")
-
>>> if fd.DoModal() == win32con.IDCANCEL: sys.exit(1)
-
...
-
>>> print fd.GetPathName().replace('\\','/')
-
C:/users/dennis/python/forum.txt
-
>>>
If I want to select multiple files and have the names returned as a list I would do something like. - import win32ui,win32con,sys
-
fd = win32ui.CreateFileDialog(1,None,None,win32con.OFN_ALLOWMULTISELECT,'All Files|*.*')
-
fd.SetOFNInitialDir('c:\\tmp')
-
fd.SetOFNTitle('Select multiple files')
-
if fd.DoModal() == win32con.IDCANCEL:sys.exit(1)
-
print fd.GetPathNames()
Which if I run it and select some random files gives me something like... - ['C:\\tmp\\Stadium.png', 'C:\\tmp\\BucksX4.png', 'C:\\tmp\\ShiftProblem.png', 'C:\\tmp\\BucksX1.png']
When working in windows, I use the code that I have pasted below. At one time I looked at all the interesting things you could do with this simple example, but have just been copying, pasting, and making minor mods for years. I have to say though that within win32 it is about as simple and straight forward as I could find. - >>> import win32ui,win32con
-
>>> fd = win32ui.CreateFileDialog(1,'','', 0,'Text |*.txt')
-
>>> fd.SetOFNTitle("Select Text File")
-
>>> if fd.DoModal() == win32con.IDCANCEL: sys.exit(1)
-
...
-
>>> print fd.GetPathName().replace('\\','/')
-
C:/users/dennis/python/forum.txt
-
>>>
If I want to select multiple files and have the names returned as a list I would do something like. - import win32ui,win32con,sys
-
fd = win32ui.CreateFileDialog(1,None,None,win32con.OFN_ALLOWMULTISELECT,'All Files|*.*')
-
fd.SetOFNInitialDir('c:\\tmp')
-
fd.SetOFNTitle('Select multiple files')
-
if fd.DoModal() == win32con.IDCANCEL:sys.exit(1)
-
print fd.GetPathNames()
Which if I run it and select some random files gives me something like... - ['C:\\tmp\\Stadium.png', 'C:\\tmp\\BucksX4.png', 'C:\\tmp\\ShiftProblem.png', 'C:\\tmp\\BucksX1.png']
A great solution, D. It's nice to know that you are still around.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: SK |
last post by:
I am calling an exe thru' href, but when it executes,
I get the message if I want to open the file(exe file).
Is there any way I can suppress this from appearing
and open the program?
Thank...
|
by: Brad |
last post by:
In several aspx applications I export crytal reports to pdf, xls and doc
files and then the aspx page writes the selected export file to the client
browser. This all works with one small quirk: ...
|
by: Matt Hamilton |
last post by:
I have an application page with a datagrid with a checkbox on each row. The
user should check the rows they want to modify and then click a button. When
the button is clicked, I have a Click...
|
by: yup |
last post by:
I was wondering if you know a way to have, let's say, you
would click on a menu bar item (where something like
file, edit, format, help options are on Microsoft Word)
and instead of opening a...
|
by: Satya |
last post by:
I am trying to display a PDF file (which I am being passed from a web
service as a binary stream) in a browser, but I am being prompted to
save the file instead. I don't want the user to be...
|
by: Neil Rossi |
last post by:
I have an issue with a particular ASP page on two web servers. Let's
call these servers Dev1 and Beta1. Both Servers are running IIS 5,
Windows 2000 SP4 with "almost" all of the latest patches.
...
|
by: OutdoorGuy |
last post by:
Greetings,
I have a "newbie" question in relation to opening files from C#. I have
a Windows form where I allow the user to type in a file extension in a
text box (e.g., "xls"). I then take...
|
by: Charlie Brookhart |
last post by:
I am trying to write a code for a button click event. When the button is
clicked, it is supposed to bring up an open file dialog box to allow the
user to select the document they which to open....
|
by: aarthiraaj |
last post by:
In my user screen I have view link, if I click this link it will go to servlet and open one word document. It is opening properly, but while opening the attachment it generate one dialog box like...
|
by: navanova |
last post by:
Greetings,
I have a problem of opening ms word and excel files on my computer. The files are there for a long time. I use to open and modify them. Suddenly, when i try to open the word files, a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
| |