Skip to content

File filter not compatible with the standard tk filedialog #30

@ajeb78

Description

@ajeb78

In tkFileBrowser it is necessary to specify file filters as e.g. filefilter=[("FITS files", "*.fit|*.fits"), ("All files", "*.*")] whereas the same filter for a standard tk filedialog would be filefilter=[("FITS files", "*.fit *.fits"), ("All files", "*.*")]

(The separator between multiple file extensions is a | instead of a space.)

This makes it much more awkward to use as a drop-in replacement. (My use case is that I'm writing a cross-platform script, and I'm quite happy with the way TK uses the native filedialogs on Windows and Mac, but on Linux the TK filedialog is astonishingly ugly and slow, so I want to use tkFileBrowser as a replacement on Linux but leave the native filedialogs on the other OSes. It should be a matter of:

if sys.platform.startswith("linux"):
    import tkfilebrowser as filedialog
else:
    from tkinter import filedialog

but it's made more complicated than it needs to be owing to have to handle the filter specifications differently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions