From 33779a22e6bad83d824b760c8fdae6c648605716 Mon Sep 17 00:00:00 2001 From: tobidelbruck Date: Fri, 19 May 2023 09:48:41 +0200 Subject: [PATCH 1/3] changed to allow specifying a particular default file if default does not contain any wildcards --- easygui/boxes/fileopen_box.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/easygui/boxes/fileopen_box.py b/easygui/boxes/fileopen_box.py index ea94eaf..880b167 100644 --- a/easygui/boxes/fileopen_box.py +++ b/easygui/boxes/fileopen_box.py @@ -30,7 +30,8 @@ def fileopenbox(msg=None, title=None, default='*', filetypes=None, multiple=Fals Displays an "open file" dialog box and returns the selected file as a string. The "default" argument specifies a filepath that (normally) - contains one or more wildcards. + contains one or more wildcards. If default contains no wildcards, + it populates the selected file dialog for easier selection by hitting Enter fileopenbox() will display only files that match the default filepath. If omitted, defaults to "\\*" (all files in the current directory). @@ -90,14 +91,14 @@ def fileopenbox(msg=None, title=None, default='*', filetypes=None, multiple=Fals default, filetypes) # ------------------------------------------------------------ - # if initialfile contains no wildcards; we don't want an - # initial file. It won't be used anyway. + # if initialfile contains no wildcards we assume user wants to specify a particular default file so they can just hit Enter to select it. # Also: if initialbase is simply "*", we don't want an # initialfile; it is not doing any useful work. # ------------------------------------------------------------ if (initialfile.find("*") < 0) and (initialfile.find("?") < 0): - initialfile = None - elif initialbase == "*": + pass + # initialfile = None + if initialbase == "*": initialfile = None func = ut.tk_FileDialog.askopenfilenames if multiple else ut.tk_FileDialog.askopenfilename @@ -126,5 +127,5 @@ def fileopenbox(msg=None, title=None, default='*', filetypes=None, multiple=Fals if __name__ == '__main__': print("Hello from file open box") - ret_val = fileopenbox("Please select a file", "My File Open dialog") + ret_val = fileopenbox(msg="Please select a file", title= "My File Open dialog", default="*.py") print("Return value is:{}".format(ret_val)) From 5d902b73b7d660ba5fd82432d78abb08ac93da7d Mon Sep 17 00:00:00 2001 From: tobidelbruck Date: Fri, 19 May 2023 10:27:33 +0200 Subject: [PATCH 2/3] Revert "changed to allow specifying a particular default file if default does not contain any wildcards" This reverts commit 33779a22e6bad83d824b760c8fdae6c648605716. --- easygui/boxes/fileopen_box.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/easygui/boxes/fileopen_box.py b/easygui/boxes/fileopen_box.py index 880b167..ea94eaf 100644 --- a/easygui/boxes/fileopen_box.py +++ b/easygui/boxes/fileopen_box.py @@ -30,8 +30,7 @@ def fileopenbox(msg=None, title=None, default='*', filetypes=None, multiple=Fals Displays an "open file" dialog box and returns the selected file as a string. The "default" argument specifies a filepath that (normally) - contains one or more wildcards. If default contains no wildcards, - it populates the selected file dialog for easier selection by hitting Enter + contains one or more wildcards. fileopenbox() will display only files that match the default filepath. If omitted, defaults to "\\*" (all files in the current directory). @@ -91,14 +90,14 @@ def fileopenbox(msg=None, title=None, default='*', filetypes=None, multiple=Fals default, filetypes) # ------------------------------------------------------------ - # if initialfile contains no wildcards we assume user wants to specify a particular default file so they can just hit Enter to select it. + # if initialfile contains no wildcards; we don't want an + # initial file. It won't be used anyway. # Also: if initialbase is simply "*", we don't want an # initialfile; it is not doing any useful work. # ------------------------------------------------------------ if (initialfile.find("*") < 0) and (initialfile.find("?") < 0): - pass - # initialfile = None - if initialbase == "*": + initialfile = None + elif initialbase == "*": initialfile = None func = ut.tk_FileDialog.askopenfilenames if multiple else ut.tk_FileDialog.askopenfilename @@ -127,5 +126,5 @@ def fileopenbox(msg=None, title=None, default='*', filetypes=None, multiple=Fals if __name__ == '__main__': print("Hello from file open box") - ret_val = fileopenbox(msg="Please select a file", title= "My File Open dialog", default="*.py") + ret_val = fileopenbox("Please select a file", "My File Open dialog") print("Return value is:{}".format(ret_val)) From 821e409a0b28976d7b07c3b7a2165c6bad916996 Mon Sep 17 00:00:00 2001 From: tobidelbruck Date: Fri, 19 May 2023 10:30:47 +0200 Subject: [PATCH 3/3] changed to allow specifying a particular default file if default does not contain any wildcards --- easygui/boxes/fileopen_box.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/easygui/boxes/fileopen_box.py b/easygui/boxes/fileopen_box.py index ea94eaf..880b167 100644 --- a/easygui/boxes/fileopen_box.py +++ b/easygui/boxes/fileopen_box.py @@ -30,7 +30,8 @@ def fileopenbox(msg=None, title=None, default='*', filetypes=None, multiple=Fals Displays an "open file" dialog box and returns the selected file as a string. The "default" argument specifies a filepath that (normally) - contains one or more wildcards. + contains one or more wildcards. If default contains no wildcards, + it populates the selected file dialog for easier selection by hitting Enter fileopenbox() will display only files that match the default filepath. If omitted, defaults to "\\*" (all files in the current directory). @@ -90,14 +91,14 @@ def fileopenbox(msg=None, title=None, default='*', filetypes=None, multiple=Fals default, filetypes) # ------------------------------------------------------------ - # if initialfile contains no wildcards; we don't want an - # initial file. It won't be used anyway. + # if initialfile contains no wildcards we assume user wants to specify a particular default file so they can just hit Enter to select it. # Also: if initialbase is simply "*", we don't want an # initialfile; it is not doing any useful work. # ------------------------------------------------------------ if (initialfile.find("*") < 0) and (initialfile.find("?") < 0): - initialfile = None - elif initialbase == "*": + pass + # initialfile = None + if initialbase == "*": initialfile = None func = ut.tk_FileDialog.askopenfilenames if multiple else ut.tk_FileDialog.askopenfilename @@ -126,5 +127,5 @@ def fileopenbox(msg=None, title=None, default='*', filetypes=None, multiple=Fals if __name__ == '__main__': print("Hello from file open box") - ret_val = fileopenbox("Please select a file", "My File Open dialog") + ret_val = fileopenbox(msg="Please select a file", title= "My File Open dialog", default="*.py") print("Return value is:{}".format(ret_val))