I am using fileopenbox() and I want to select all text files I have when the windows box is open. I have tried to press shift or ctrl + A, but it didn't work.
openfile = fileopenbox("Welcome", "COPR", filetypes= "*.txt")
You can select multiple files if you include multiple=True in the arguments:
openfiles = fileopenbox("Welcome", "COPR", filetypes= "*.txt", multiple=True)
Note that now fileopenbox will return not a string, but a list of strings like:
["foo.txt", "Hello.txt", "mytxt.txt"]
another option could be using tkinter as follows(python 3.x):
import tkinter as tk
from tkinter import filedialog
root = tk.Tk()
root.withdraw()
files = filedialog.askopenfilenames(parent=root, initialdir="/", title='Please select files')
It's not possible with easygui. What you can do is reuse the code from easygui (see line 1700) and modify it slightly to use askopenfilenames
instead of askopenfilename
.