libdesktop.dialog

A module for native system dialogs (file, printing, etc).

dialog.files

Submodule for file dialogs (open, save, etc)

libdesktop.dialog.files.open_file(default_dir='~', extensions=None, title='Choose a file', multiple_files=False, directory=False)[source]

Start the native file dialog for opening file(s).

Starts the system native file dialog in order to open a file (or multiple files).

The toolkit used for each platform:

Note on Dependencies

It depends on pywin32 for Windows (installed by default in Python for Windows) It depends on PyQt for KDE and LxQt (usually installed by default on these). It depends on PyGObject for GNOME etc. (virtually every Linux desktop has this). It depends on PyGTK for other desktops (not usually installed, so has a GTK+ 3 fallback).

Parameters:
  • default_dir (str) – The directory to start the dialog in. Default: User home directory.
  • extensions (dict) –

    The extensions to filter by. Format:

    {
      'Filter Name (example: Image Files)': ['*.png', '*.whatever', '*']
    }
    
  • title (str) – The title of the dialog. Default: Choose a file
  • multiple_files (bool) – Whether to choose multiple files or single files only. Default: False
  • directory (bool) – Whether to choose directories. Default: False
Returns:

list of str s (each str being a selected file). If nothing is selected/dialog is cancelled, it is None.

Return type:

list