0

I want to set EasyGUI fileopenbox() to filter more filetypes and not just one.

Here below is a code I tried but instead of custom files selection i get more selections.

file=easygui.fileopenbox(title='Select image', filetypes=('*.png', '*.jpg'))

How to fix this?

1 Answer 1

0

From docs

About the “filetypes” argument

If specified, it should contain a list of items, where each item is either:

  • a string containing a filemask # e.g. “*.txt”

  • a list of strings, where all of the strings except the last one are filemasks (each beginning with “.”, such as “.txt” for text files, “*.py” for Python files, etc.). and the last string contains a filetype description

EXAMPLE:

filetypes = ["*.css", ["*.htm", "*.html", "HTML files"] ]

So corresponding to your usecase, you can write:

file=easygui.fileopenbox(title='Select image', filetypes=[["*.png", "*.jpg", "Image files"]])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.