PySimpleGUI / PySimpleGUI

Python GUIs for Humans! PySimpleGUI is the top-rated Python application development environment. Launched in 2018 and actively developed, maintained, and supported in 2024. Transforms tkinter, Qt, WxPython, and Remi into a simple, intuitive, and fun experience for both hobbyists and expert users.

Home Page:https://www.PySimpleGUI.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] File(s)Browse buttons ignore file_types= param on Mac

resnbl opened this issue · comments

Type of Issue (Enhancement, Error, Bug, Question)

Bug


Environment

Operating System

Mac version 12.3.1

PySimpleGUI Port (tkinter, Qt, Wx, Web)

tkinter


Versions

Python version (sg.sys.version)

3.10.1 (main, Jan 20 2022, 08:29:54) [Clang 13.0.0 (clang-1300.0.29.30)]

PySimpleGUI Version (sg.__version__)

4.59.0

GUI Version (tkinter (sg.tclversion_detailed), PySide2, WxPython, Remi)

8.6.12


Your Experience In Months or Years (optional)

2 Years Python programming experience
40 Years Programming experience overall
Yes Have used another Python GUI Framework? (tkinter, Qt, etc) (yes/no is fine)


Troubleshooting

These items may solve your problem. Please check those you've done by changing - [ ] to - [X]

  • Searched main docs for your problem www.PySimpleGUI.org
  • Looked for Demo Programs that are similar to your goal Demos.PySimpleGUI.org
  • If not tkinter - looked for Demo Programs for specific port
  • For non tkinter - Looked at readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
  • Run your program outside of your debugger (from a command line)
  • Searched through Issues (open and closed) to see if already reported Issues.PySimpleGUI.org
  • Tried using the PySimpleGUI.py file on GitHub. Your problem may have already been fixed but not released

Detailed Description

The FileBrowse and FilesBrowse buttons ignores the file_types= argument on the Mac. Note that popup_get_file() works correctly.

In the ButtonCallBack() function there is:

elif self.BType == BUTTON_TYPE_BROWSE_FILE:
    if running_mac():
        file_name = tk.filedialog.askopenfilename(initialdir=self.InitialFolder)
    else:
        file_name = tk.filedialog.askopenfilename(filetypes=filetypes,
                                                  initialdir=self.InitialFolder, parent=self.ParentForm.TKroot)

The filetypes parameter is missing for the Mac call. (And again for BUTTON_TYPE_BROWSE_FILES.)

Code To Duplicate

# Paste your code here

Screenshot, Sketch, or Drawing

Duplicate as issue #1726

Before the content of the link to https://pysimplegui.readthedocs.io/en/latest/#buttonmenu-element, you can find

NOTE - Mac users will not be able to use the file_types parameter. tkinter has a bug on Macs that will crash the program is a file_type is attempted so that feature had to be removed. Sorry about that!

Please re-consider your response after reading the comment I added to #1726 ...

Note that if this is really a short-coming on the Mac, then popup_get_file() should have the same guard logic that FileBrowse() does. See the attached screen shot of filtering only *.json files on Mac:

Screen Shot 2022-04-29 at 10 50 20 AM

Edit: added a marginally better screenshot using file_types=[('JSON files', '*.json'), ('All files', '*.* *')] with the "Options" dialog button clicked:
Screen Shot 2022-04-29 at 2 03 51 PM

file_types

filter file types, Default value = ( ("ALL Files", ". *"), )
format Tuple[(str, str), ...]

NOTE - Mac users will not be able to use the file_types parameter. tkinter has a bug on Macs that will crash the program is a file_type is attempted so that feature had to be removed. Sorry about that!

The root cause is not the wrong format provided by programmer.

I don't have the information why the program will crash when a file_type is attempted so that feature had to be removed.

Maybe @PySimpleGUI will tell us later.

Note: For MacOS,

It seems that there are 5 arguments in tk.filedialog.~ for file popup

  • filetypes,
  • initialdir,
  • initialfile,
  • parent,
  • defaultextension

but only one argument in tk.filedialog.~ for file Button element

  • initialdir

Much has changed with tkinter on the Mac since 2018.... much has changed with me as well I suppose.

For example, when PySimpleGUI was released, you have one choice for the color of a button on the Mac. White. Was it. The Tk.Button code was just plain broke. It's why ttk Buttons were implemented, to get around a rather significant bug in tkinter.

I don't recall now all of the details under all this and the issues were created long before the Issues form was created. It was added exactly for these kinds of reasons, so that we have a history of the version numbers, etc.

There is an entire section of the Global Settings devoted to enabling and disabling feature sets on the Mac for a reason

image

These were not problems due to ignorance, in my opinion, these were and are very real problems.

If something was a problem and no longer isn't, I have no problem adding an option to control the feature. I do not feel comfortable dropping in code that may crash on older systems. The Mac was nearly dropped entirely from PySimpleGUI as I wrestled with significant problems.... It's always been a balance and while not publicly stated, there is always a "weighing operation" that goes on in my head as to whether it's worth it to continue to support the Mac. "Is it worth it?"

I don't have the hardware nor the software to recreate the setups and problems from the past. But we do have users out in the field that are still running these older systems. My point is that it's not as simple as "look, it runs".

@jason990420 wrote:

The root cause is not the wrong format provided by programmer.

I tend to disagree on that: see the additional comment on #1726 where I duplicated his error in tkinter. It is resolved by correcting their tuple syntax.

@PySimpleGUI I understand your reluctance to make a change. By the same token, this means I expect you won't "fix" the popup_get_file() acceptance of the filetypes parameter, and I can therefore get the same result I'm seeking through that route.

@PySimpleGUI I understand your reluctance to make a change.

Thank you for your understanding.

By the same token, this means I expect you won't "fix" the popup_get_file() acceptance of the filetypes parameter, and I can therefore get the same result I'm seeking through that route.

I don't think this characterizes my concern.

Well, I was being a little glib... sorry about that. However, I would like some assurance that making use of filetypes with popup_get_file() won't suddenly disappear in the next release. If not, I must implement that functionality with a direct call to tk.filedialog.askopenfilename() (not that big of a deal).

In my 40+ years as a professional programmer, I have seen more than a few occasions of "superstitious learning" where advice is given to "don't do X..." and everyone blindly follows along. In fact, the original person forgot a required prior step, or "did X" in the wrong context, or... This particular issue has that same smell to me.

@jason990420 wrote:

The root cause is not the wrong format provided by programmer.

I tend to disagree on that: see the additional comment on #1726 where I duplicated his error in tkinter. It is resolved by correcting their tuple syntax.

What I mean not for the issue in #1726, but for the argument file_type ignored in file-type Button element for MacOS.

If I've made a mistake, and I'm leaning towards I likely did, it would be foolish for me to hold onto the position of that mistake.... it would make the product not better, but worse. I've barely looked at this.

I wanted yesterday to respond out of respect/courtesy more than trying to be right or make a bigger point. Maybe I shouldn't have. I'm not the best at "give it time"...despite writing those very words every morning on paper to remind myself.

I SO appreciate the time and care you're putting into this Bob.... I should have perhaps said that upfront yesterday. I responded at the end of a long day, ill-prepared, and looking more defensive than open seen through this morning's eyes. I'm open..lemme be really clear about that. I'm quick to admit my mistakes... I think, I hope, I strive to... and to fix them. This may very well be one I made some time ago, and I'll both admit and fix it. I just need a little bit to wrap my head around all the data that's flying around.

Added back in version 4.59.0.37 which is now posted on GitHub. Thanks Bob!

Can I get some feedback on the latest on GitHub that I've done the right changes and that they work? 4.60.0 is going to get released as soon as I can. I've got more to go yet, but want to get this checked off the list as done and tested if possible.

Looks good to me:
Screen Shot 2022-05-04 at 2 04 08 PM

GOAL!

image

Thanks very much Bob!

I appreciate the help, the patience, the persistence.... it's made PySimpleGUI better.

Maybe I didn't get it right afterall?

#5434

I would like some assurance that making use of filetypes with popup_get_file() won't suddenly disappear in the next release.

It won't be sudden, but if this crash is valid, then, yes, it will disappear.

Oh... but wait.... perhaps not a valid crash, one that @resnbl predicted. I need to add some protection from this.

That's the fix I didn't put in...

image

Okey dokey.... 4.59.0.40 now actively looks for this situation, corrects it, and warns the user to fix the parameter when it happens with the Browse Buttons. I'll add the same to the popup code next.

This is going to have to wait until 4.61.0 when I can add code to the Mac Control Panel. In the meantime, we're back to the parameter being unavailable through the PySimpleGUI interface.

This is turning into an enhancement request. The approach I'm considering is adding a setting in the Global Settings that will enable the use of this parm.

Because the Mac doesn't assert but instead doe a full-on panic, my attempt to mediate the problem using try blocks (see the other issue #5434) failed and thus I needed to remove the code.

I'm open to having the capability available for those users that it doesn't crash for. I just have to protect those users that it DOES crash.

"Ya gotta do what ya gotta do..."
Notes: I found a copy of Python 3.9.12 hiding on my machine, and was unable to reproduce the crash from #5434. Of course, I'm running an OS that is 2 versions newer than that issue used. This was using the following tkinter-only test app:

import platform
import sys
import tkinter
import tkinter.filedialog

print('Mac OS:', platform.mac_ver()[0])
print('Python:', sys.version)
tcl = tkinter.Tcl()
print('tkinter:', tcl.call('info', 'patchlevel'))

# ft = (("Python files", "*.py"),)
# ft = (("All files", "*.* *"),)
# ft = (("Text files", "*.txt"), ("All files", "*.* *"))
# ft = (())
ft = (("Python files", "*.py"))
fn = tkinter.filedialog.askopenfilename(filetypes=ft, initialdir='.')
# fn = tkinter.filedialog.askopenfilename()
print(f'{fn=}')

Even the last test only threw a _tkinter.TclError exception, not a crash.

One thing I did notice: running this test with Python 3.10 only displayed the file open dialog (as expected). But on Python 3.9, an additional small, empty "tk" window was displayed as well (?...).

Additionally, the OP's Python version was listed as 3.9.12 (main, Mar 25 2022, 00:55:04) [Clang 7.0.2 (clang-700.1.81)] but mine is: 3.9.12 (main, Mar 26 2022, 15:51:15) [Clang 13.1.6 (clang-1316.0.21.2)]

I know my 3.9, and I suspect the OP's 3.9 as well, were installed via Homebrew on the Mac, which actually compiles and builds Python, as opposed to a straight download from Python.org. I'd bet if the OP did a brew update for Python, they'd get a different result...

Hia Bob! Nice to see you back on this. My priority, and concern, continue to be the install base. It's wonderful that it all works now, on the latest and greatest software for the Mac. But PySimpleGUI is meant to run back to version 3.4, on older systems. Forcing the existing users to upgrade their environment or else their application will panic and crash is not in the realm of possibilities.

The plan I've published is to make this parm available to Mac users, but in a way that protects the install base and users that don't know if their machine is going to crash.

"Ya gotta do what ya gotta do..."

Doing my best to do.... want to make this parm available for those that can use it.

4.60.0.3 now has the additional option in the Mac Feature Control.

It's disabled by default. If you enable it, then the file_types parameter should work for the Mac.

image

Flipping this one back to DONE as I believe 4.60.0.3 has a solution that provides the access you're after, @resnbl , as well as the protection that's needed for the install base.

I experimented with this version.

It's a good solution to avoid crashing but in exchange of losing the input filter...

IMO a better solution would be to automatically deenable for macOS platforms, with programmatic reactivation on demand (a specific FileBrowse setting, with a warning) with knowledge.

Input filter is lost?

automatically deenable for macOS platforms, with programmatic reactivation on demand (a specific FileBrowse setting, with a warning) with knowledge.

I have no clue what this means

macOS: 10.10.5

  1. floating-screenshot-205140

lost of filter => file_types=(('PDF files', '*.pdf'),) is disabled

floating-screenshot-204255

floating-screenshot-210250

  1. floating-screenshot-210808

filter OK but crash with file_types=(('ALL files', '*.*'),)

Oh, I see.... file_types is the filter.

The other way to look at this is in a positive light, is that the Mac developers are getting the file_types parameter that was removed 2 years ago. It's not been available for quite a long time. This code is now making it possible. I'm looking at this in the positive light of "the Mac users are now able to access the parameter" rather than it has to be enabled and that's bad. We can skip the whole checkbox and just go back to it being disabled if checking the box to enable it really feels terrible. I'm looking for a balance here and this seemed to be the best balance I can find.

What I will not do is publish software that will crash existing deployments. I'm not going to be badgered into that.

Some programs are out there that have been given to customers and the developer isn't around to go into the settings and turn it off if it starts to crash. The end user's ability to function is always going to come before a programmer's convenience.

The default is going to be for it to be off. If checking the checkbox, once, is too much for Mac programmers, I'm happy to rollback the work I've done on this feature.

Works fine for me, after enabling the global setting.
Mac OS: 12.3.1
Python: 3.10.1 (main, Jan 20 2022, 08:29:54) [Clang 13.0.0 (clang-1300.0.29.30)]
tkinter: 8.6.12
4.60.0.3 Unreleased PySimpleGUI

BTW: you can enable this Mac setting at run-time via via:
sg.pysimplegui_user_settings['-mac feature enable file_types-'] = True

automatically deenable for macOS platforms, with programmatic reactivation on demand (a specific FileBrowse setting, with a warning) with knowledge.

I have no clue what this means

floating-screenshot-210808
can set automatically for macOS to be in the safe side for installed base.

But this set
floating-screenshot-205140
can be made by a user code at his own risk ;-)
I hope to be clearer :-)

BTW: you can enable this Mac setting at run-time via via:
sg.pysimplegui_user_settings['-mac feature enable file_types-'] = True

Thank you @resnbl I like this but a kind of hacking (permanence?)

Using only the command I listed above, this setting will only continue for the duration of the program's execution. However, if you read up on global settings, you can create your own settings file for, say, a particular program and avoid dealing with the machine/user-wide global control panel. Note that using the above statement always overrides the global setting.

Of course, you can always "roll your own" config and simply use that mechanism to then issue the above command at the beginning of your program.

Using only the command I listed above, this setting will only continue for the duration of the program's execution.

Assuming you're talking about this line of code:

sg.pysimplegui_user_settings['-mac feature enable file_types-'] = True

It permanently changes the value in the settings. You will only need to execute it one time.

Oh my...I just tested that and you are correct. @macdeport ignore what I said!
Is there a way to set that item just for the duration of the current program?
Or would we need to save the current value, update it, then restore the value before exiting?

Update: I was able to kludge "single program execution only" effects with:

sg.pysimplegui_user_settings.autosave = False
sg.pysimplegui_user_settings['-mac feature enable file_types-'] = True

After my program quit, there were no changes to the global settings file.

Or would we need to save the current value, update it, then restore the value before exiting?

This would work fine, until you have 2 programs running at the same time which creates a race condition that will bite you eventually.

The purpose of this feature isn't meant to be a temporary thing. Either your system is going to work or it's not. That's how I'm reading this Mac bug. Maybe I'm still misunderstanding, but I was under the impression it works or it doesn't depending on the Mac OS.

sg.pysimplegui_user_settings.autosave = False

For clarity... this is not a documented feature/property and thus subject to change. Same with the key being used in the JSON file. It's great for testing, but it's not safe for production.

I don't have a problem with you going under the hood and manipulating and using implementation-specific internals to PySimpleGUI, I just want to make sure future users understand that these are non-documented, and potentially risky pieces of code.

It could be OS level dependent, or it could depend on the version of Python/Tkinter, or how it was installed (Homebrew actually compiles Tkinter using the required C compiler from Apple's Xcode package, which may be OS-level sensitive itself!). I don't think we have enough data points to specifically point to a single culprit.

The other issue I see is how distributors get end clients to invoke the control panel and drill down to the necessary Mac option, especially if the product is not installed via pip.

All that said, I'm going to back away from this now as I have a solution for myself. (And I'll be involved in a non-computer project for the next week or so...)

The other issue I see is how distributors get end clients to invoke the control panel and drill down to the necessary Mac option, especially if the product is not installed via pip.

Issues are great. Scenarios are great to understand. Clarity is also good so that users understand when a hack is being employed versus a documented feature.

Making this investment for Mac users so they can safely use features is something I'm behind or wouldn't be spending the time and expense to jump through the hoops to make it happen.

We're taking the time to investigate down into the lower layers, outside of PySimpleGUI, to try to find the root cause of the crash and then specifically add code that will get past the lower level bug. It's an ongoing effort and has been for the past 17 days. I met with @Chr0nicT this morning for an hour on this issue.

See you in a few weeks. Let us know when you're once again available to help out.

OK! Let's try another approach....

Just uploaded 4.60.0.17

This one removes the need for system settings by working around the problem.

Can the Mac users give it a go and see if it works on the systems that crashed previously?

I've only changed the Browse button in this release. The popup hasn't been changed. There's no use changing the popup if the main browse doesn't work.

Credit goes to @Chr0nicT if this works out well... blame is on me if there's a problem as it likely means I did something wrong.

Credit goes to both :-)

Very nice of you, but I gotta give all the credit to @Chr0nicT for putting in a lot of time and effort to figure out a solution that works across the board. It took a lot of trial and error. Thanks for the encouragement image. Doing our best with the Mac. He's getting an M1 next week so we'll be able to do more testing of these M1 specific problems.

@macdeport - just so I understand clearly... you were able to test the new code on the machine that crashes if you try using the older code?

What would be great is if the code you originally posted in your issue was tried with both an earlier version and 4.60.0.17+

#5434

You showed that this code:

import PySimpleGUI as sg
print(sg.__version__)

layout = [[sg.FileBrowse()]]

window = sg.Window('FileBrowse()', layout)

while True:
    
    event, values = window.read()
    print(f'1 {event=}\n   {values=}')
    
    if event == sg.WIN_CLOSED:
       break

window.close()

crashed as soon as you clicked the Browse button.

If 4.60.0.17 works and the older code crashes, then I should be able to take out the need for the Mac control panel change so that all of the legacy code will run without crashing.

@macdeport - just so I understand clearly... you were able to test the new code on the machine that crashes if you try using the older code?

@PySimpleGUI you understand well: all such troubles have disappeared with 4.60.0.17 on macOS 10.10.5 👍

Three conditions are needed for crash:

  1. PSG version < 4.60.0.17
    &
  2. image
    &
  3. file_types=(('ALL files', '*.*'),)

If 4.60.0.17 works and the older code crashes, then I should be able to take out the need for the Mac control panel change so that all of the legacy code will run without crashing.

Absolutely

To test with version PSG version < 4.60.0.17 can you remind me the right pip command line?

This will install the last PyPI released version (4.60.1)

pip install PySimpleGUI==4.60.1

image

I left the code in the Mac Control panel, but it's not used in the Browse Buttons now. I wanted to make sure it's all working before I go tearing out that code.

To rewind the TIME i.e to reproduce the crash, I need "4.60.0.3 Unreleased PySimpleGUI" and corresponding "Mac PySimpleGUI Feature Control"...
Where such files can be downloaded?

You just need to test code that was previously released and crashed and this current code. I don't understand the reason for needing that specific version to test what I'm requesting.

I mistakenly thought that I had to check before (again) and after...

4 versions of layout tested:

layout = [[sg.FileBrowse()]]
layout = [[sg.FileBrowse(file_types = (('ALL files', '*.*'),))]]
layout = [[sg.FileBrowse(file_types = (('ALL TXT files', '*.txt'),))]]
layout = [[sg.FileBrowse(file_types = (('ALL files', '*.*'), ('ALL TXT files', '*.txt')))]]
4.60.0.21
event=None
   values={'Browse': None}

So no more crash but issue with this 4th layout:

Please notice on screen shot "Filter:" popup menu (2 items ('ALL files', '.'), ('ALL TXT files', '*.txt')) selection changes between screen shots in chronological order.

1st screen shot: <= It is wrong because the 1st filter ('ALL files', '.') is well selected, as expected, but the file display is not in agreement (it is the 2nd filter ('ALL TXT files', '*.txt') one!)

floating-screenshot-232955

2nd screen shot: OK

floating-screenshot-233135

3rd screen shot: OK (no issue if it was the 1st one... compare with the 1st one)

floating-screenshot-233302

No problem... glad I was able to get some clarity for you. Thanks for all this help!

Can you explain what you mean by the glitch? I don't understand exactly what's wrong. Can you tell me what you expected to see and what you see instead?

I will try to be clearer in editing previous #5418... let me know.

To complete (?) the test filter

layout = [[sg.FileBrowse(file_types = (('ALL TXT files', '*.txt'), ('ALL files', '*.*')))]]

was tried: perfectly OK.

Let's keep the conversation in this one issue....

I believe you're saying that in terms of crashing, no crashes, at all.

But, there's a problem with the Mac showing . correctly.

Can you try swapping the filters to see if it has an effect?

layout = [[sg.FileBrowse(file_types = (('ALL TXT files', '*.txt'), ('ALL files', '*.*')))]]

and also this one with them swapped

layout = [[sg.FileBrowse(file_types = ( ('ALL files', '*.*'), ('ALL TXT files', '*.txt')))]]

It shouldn't matter, of course, but maybe it'll have an impact. I'm searching for a way to give instructions to users for a path, any path, that works.

Or maybe try it with all files specified as "*"?

At least it doesn't crash anymore!
image

Let focus of the main issue.

To summarize at present I have tested 14 file_types configs:

None
file_types=(('ALL files', '*'),)
file_types=(('ALL files', '.*'),)
file_types=(('ALL files', '*.'),)
file_types=(('ALL files', '*.*'),)
file_types=(('ALL TXT files', '*.txt'),)
file_types=(('ALL files', '.*'), ('ALL TXT files', '*.txt'))
file_types=(('ALL files', '*.'), ('ALL TXT files', '*.txt'))
file_types=(('ALL files', '*'), ('ALL TXT files', '*.txt'))
file_types=(('ALL files', '*.*'), ('ALL TXT files', '*.txt'))
file_types=(('ALL TXT files', '*.txt'), ('ALL files', '*'))
file_types=(('ALL TXT files', '*.txt'), ('ALL files', '.*'))
file_types=(('ALL TXT files', '*.txt'), ('ALL files', '*.'))
file_types=(('ALL TXT files', '*.txt'), ('ALL files', '*.*'))

These 3/14 configs only still lead (4.60.0.21) to crash :-(

file_types=(('ALL files', '*'),)
file_types=(('ALL files', '.*'),)
file_types=(('ALL files', '*.'),)

Ah, very veyr very good! I'll add those file_types to the code.

The trick is to catch all of the "*" type of definitions, and when they are the only thing being specified, to ignore them and to not pass them to the call. THIS is the beautifully magical thing the @Chr0nicT discovered. It took several days, but he eventually found the root cause and how to avoid it. I'll add your new finds to the code and we'll keep trying! Thank you again SO MUCH!

The first one in your crash list should have been OK:

file_types=(('ALL files', '*'),)

This is one that's specifically checked just like .. Let me add the others and you can check those that crashed again....

OK! Give 4.0.60.23 a try please. It has the additional ways of specifying *

Thank you again @macdeport for the help!

I will test.
But of course '* *.*' (I have a look on your filter) will lead to crash and any combination of crashing items too...
A more bullet proof simple filter can be used: are you ok I suggest one?

These are the values I'm testing against.

("*", "*.*", "*.* *", "*.", '.*')

Sure, I'm open to suggestions.

4.60.0.24 adds the missing combination * *.*

I'll do a regex next if that doesn't cover all the situations :-)

I think this test will cover checking for the condition we're after...

all(ch in '* .' for ch in y)

In 4.0.60.25 I've added the more general purpose logic that should cover all combinations of using *

"Simple" and bullet proof! 👍

image

Yeah!

I do like simple.... it takes me a while to get there.... but I usually eventually arrive.

Thank you for all the help. Couldn't have made it without the assistance.

It's a pleasure :-)

I'll make the change to the popup_get_file today as well as remove the Mac control panel settings for this feature so that everyone has access on all Macs.

Just posted 4.60.0.28 which has 2 changes for the Mac

  1. Removed the setting that controlled access to the filetypes parameter from the Mac System Settings
  2. Added the same fix for file_types to popup_get_file that was added to the Browse buttons

@macdeport can I bother you to try a test of popup_get_file? There are 2 ways that popup_get_file accesses the dialog box so they both need testing. The parameter to control these 2 accesses is the no_window parameter.

Seems OK for 19 tests x 2

import PySimpleGUI as sg
print(sg.__version__)

file_types=None
file_types=(('ALL files', '.*'),)
file_types=(('ALL files', '*.'),)
file_types=(('ALL files', '*'),)
file_types=(('ALL files', '*.*'),)
file_types=(('ALL files', '* *.*'),)
file_types=(('ALL files', '.* *.*'),)
file_types=(('ALL files', '*. *.*'),)
file_types=(('ALL files', '. *.*'),)
file_types=(('ALL files', '*.* *'),)
file_types=(('ALL TXT files', '*.txt'),)
file_types=(('ALL files', '.*'), ('ALL TXT files', '*.txt'))
file_types=(('ALL files', '*.'), ('ALL TXT files', '*.txt'))
file_types=(('ALL files', '*'), ('ALL TXT files', '*.txt'))
file_types=(('ALL files', '*.*'), ('ALL TXT files', '*.txt'))
file_types=(('ALL TXT files', '*.txt'), ('ALL files', '*'))
file_types=(('ALL TXT files', '*.txt'), ('ALL files', '.*'))
#file_types=(('ALL TXT files', '*.txt'), ('ALL files', '*.'))
#file_types=(('ALL TXT files', '*.txt'), ('ALL files', '*.*'))

s=sg.popup_get_file('message',file_types=file_types,no_window=True)
print(f'{s!r}\n')

@macdeport I really appreciate your help!
image