user17279264
user17279264

Reputation:

Python EasyGUI fileopenbox() filter more items

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?

Upvotes: 0

Views: 415

Answers (1)

RusheN
RusheN

Reputation: 16

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"]])

Upvotes: 0

Related Questions