Giving try blocks a go to see if can fix the file_types problem on the Mac
This commit is contained in:
parent
e0b5aff6a8
commit
0a7736ea93
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
version = __version__ = "4.59.0.41 Released 5-Apr-2022"
|
||||
version = __version__ = "4.59.0.42 Released 5-Apr-2022"
|
||||
|
||||
_change_log = """
|
||||
Changelog since 4.59.0 released to PyPI on 5-Apr-2022
|
||||
|
@ -141,6 +141,8 @@ _change_log = """
|
|||
Auto-correct file_types problems for Browse buttons. Automatically change the formatting from (str, str) to ((str, str),) and warn the user
|
||||
4.59.0.41
|
||||
Docstring typo fixes for file_types parm
|
||||
4.59.0.42
|
||||
FileBrowse - giving a series of try blocks a try to see if can get around the Mac file_types issue
|
||||
"""
|
||||
|
||||
__version__ = version.split()[0] # For PEP 396 and PEP 345
|
||||
|
@ -4946,8 +4948,14 @@ class Button(Element):
|
|||
else: # if "cancel" button clicked, don't generate an event
|
||||
should_submit_window = False
|
||||
elif self.BType == BUTTON_TYPE_BROWSE_FILE:
|
||||
file_name = tk.filedialog.askopenfilename(filetypes=filetypes, initialdir=self.InitialFolder,
|
||||
parent=self.ParentForm.TKroot if not running_mac() else None) # show the 'get file' dialog box
|
||||
try:
|
||||
file_name = tk.filedialog.askopenfilename(filetypes=filetypes, initialdir=self.InitialFolder, parent=self.ParentForm.TKroot if not running_mac() else None) # show the 'get file' dialog box
|
||||
except:
|
||||
try:
|
||||
file_name = tk.filedialog.askopenfilename(initialdir=self.InitialFolder, parent=self.ParentForm.TKroot if not running_mac() else None) # show the 'get file' dialog box
|
||||
except:
|
||||
file_name = None
|
||||
|
||||
if file_name:
|
||||
strvar.set(file_name)
|
||||
self.TKStringVar.set(file_name)
|
||||
|
@ -4959,8 +4967,16 @@ class Button(Element):
|
|||
strvar.set(color)
|
||||
self.TKStringVar.set(color)
|
||||
elif self.BType == BUTTON_TYPE_BROWSE_FILES:
|
||||
file_name = tk.filedialog.askopenfilenames(filetypes=filetypes, initialdir=self.InitialFolder,
|
||||
parent=self.ParentForm.TKroot if not running_mac() else None)
|
||||
try:
|
||||
file_name = tk.filedialog.askopenfilenames(filetypes=filetypes, initialdir=self.InitialFolder, parent=self.ParentForm.TKroot if not running_mac() else None)
|
||||
|
||||
except:
|
||||
try:
|
||||
file_name = tk.filedialog.askopenfilenames(initialdir=self.InitialFolder, parent=self.ParentForm.TKroot if not running_mac() else None)
|
||||
|
||||
except:
|
||||
file_name = None
|
||||
|
||||
if file_name:
|
||||
file_name = self._files_delimiter.join(file_name) # normally a ';'
|
||||
strvar.set(file_name)
|
||||
|
@ -4969,8 +4985,14 @@ class Button(Element):
|
|||
should_submit_window = False
|
||||
elif self.BType == BUTTON_TYPE_SAVEAS_FILE:
|
||||
# show the 'get file' dialog box
|
||||
file_name = tk.filedialog.asksaveasfilename(filetypes=filetypes, defaultextension=self.DefaultExtension, initialdir=self.InitialFolder,
|
||||
parent=self.ParentForm.TKroot if not running_mac() else None)
|
||||
try:
|
||||
file_name = tk.filedialog.asksaveasfilename(filetypes=filetypes, defaultextension=self.DefaultExtension, initialdir=self.InitialFolder, parent=self.ParentForm.TKroot if not running_mac() else None)
|
||||
except:
|
||||
try:
|
||||
file_name = tk.filedialog.asksaveasfilename(defaultextension=self.DefaultExtension, initialdir=self.InitialFolder, parent=self.ParentForm.TKroot if not running_mac() else None)
|
||||
except:
|
||||
file_name = None
|
||||
|
||||
if file_name:
|
||||
strvar.set(file_name)
|
||||
self.TKStringVar.set(file_name)
|
||||
|
|
Loading…
Reference in New Issue