Skip to main content

A Python wrapper for opening files and folders with the native file dialog.

Project description

CrossFileDialog

A Python wrapper for opening files and folders with the native file dialog.

Makes it easy to prompt the user with a native filepicker on all supported platforms.

Currently supports:

  • Zenity (GTK)
  • KDialog (KDE)
  • Windows 2000 and newer (via PyWin32)
  • osascript (macOS)

Basic API usage:

import crossfiledialog

filename = crossfiledialog.open_file()
multiple_filenames = crossfiledialog.open_multiple()
save_filename = crossfiledialog.save_file()
foldername = crossfiledialog.choose_folder()

Documentation

crossfiledialog.open_file(title, start_dir, filter) -> str

Open a file selection dialog for selecting a file.

Parameters:

  • title (str, optional) — The title of the file selection dialog. Default is 'Choose a file'
  • start_dir (str, optional) — The starting directory for the dialog.
  • filter (str, list, dict, optional) — The filter for file types to display. It can be either:
    • a single wildcard (e.g.: "*.py", all files are displayed ending .py)
    • a list of wildcards (e.g.: ["*.py" "*.md"], all files are displayed ending either .py or .md)
    • a list of list optional one or more wildcards (e.g.: [["*.py", "*.md"], ["*.txt"]], user can switch between (.py, .md) and (.txt))
    • a dictionary mapping descriptions to wildcards (e.g.: {"PDF-Files": "*.pdf", "Python Project": ["\*.py", "*.md"]})

Returns:

  • str: The selected file's path.

crossfiledialog.open_multiple(title, start_dir, filter) -> list[str]

Open a file selection dialog for selecting multiple files.

Parameters:

  • title (str, optional) — The title of the file selection dialog. Default is 'Choose one or more files'
  • start_dir (str, optional) — The starting directory for the dialog.
  • filter (str, list, dict, optional) — The filter for file types to display. It can be either:
    • a single wildcard (e.g.: "*.py", all files are displayed ending .py)
    • a list of wildcards (e.g.: ["*.py" "*.md"], all files are displayed ending either .py or .md)
    • a list of list optional one or more wildcards (e.g.: [["*.py", "*.md"], ["*.txt"]], user can switch between (.py, .md) and (.txt))
    • a dictionary mapping descriptions to wildcards (e.g.: {"PDF-Files": "*.pdf", "Python Project": ["\*.py", "*.md"]})

Returns:

  • list[str]: A list of selected file paths.

crossfiledialog.save_file(title, start_dir) -> str

Open a save file dialog.

Parameters:

  • title (str, optional) — The title of the file selection dialog. Default is 'Enter the name of the file to save to'
  • start_dir (str, optional) — The starting directory for the dialog.

Returns:

  • str: The selected file's path for saving.

crossfiledialog.save_file(title, start_dir) -> str

Open a folder selection dialog.

Parameters:

  • title (str, optional) — The title of the file selection dialog. Default is 'Choose a folder'
  • start_dir (str, optional) — The starting directory for the dialog.

Returns:

  • str: The selected folder's path.

Licence

This software is licensed under the GNU LGPL 3.0 Only. See the LICENSE file for details.

SPDX-License-Identifier: LGPL-3.0-only

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crossfiledialog-1.2.0.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crossfiledialog-1.2.0-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

Details for the file crossfiledialog-1.2.0.tar.gz.

File metadata

  • Download URL: crossfiledialog-1.2.0.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for crossfiledialog-1.2.0.tar.gz
Algorithm Hash digest
SHA256 98316a4721747f98ebfecb4350ec159ef19d23e5c8301022c9fdfd89aa0eb12b
MD5 f069b977f4aaba6545b7b6b122b5a7c4
BLAKE2b-256 e8de430ee4912083a7516c2c7a22af8aa32c526d0ce94f9767cc8335a5c4a0cb

See more details on using hashes here.

File details

Details for the file crossfiledialog-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for crossfiledialog-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 30c478aa39660b9ed6ac4f0a20c7211f54bb345683a662f9de0b31e87fdc0292
MD5 858f7757c10a062feda284fd85d95cbe
BLAKE2b-256 8f30a1662e71c84327163c0cd37b56a433287089f6d6ea382a628d1b1996f71d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page