No project description provided
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:
- GTK (via PyGObject, Zenity)
- KDE (via KDialog)
- Qt5/6 (via pyqt5/pyqt6)
- Windows 2000 and newer (via PyWin32)
Note
Guys, I really don't know why, but why does QT and Kdialog have the same UI in my computer? Can someone who knows open an issue and explain it to me? Thank you!
Edit: The explanation has been provided in this issue comment.
If you know how to add the file picker for MacOS, please consider doing so and make a pull request for it.
Basic API usage
from crossfiledialog import file_dialog
CrossFileDialog = file_dialog(["zenity"])
filename = CrossFileDialog.open_file()
multiple_filenames = CrossFileDialog.open_multiple()
save_filename = CrossFileDialog.save_file()
foldername = CrossFileDialog.choose_folder()
Documentation
file_dialog(picker_preference: Optional[list[str]] = None) -> BaseFileDialog
From a list of (optional) file picker preferences, return the first available implementation.
Args:
- picker_preference (
Optional[list[str]], optional): Order of precedence for picking the file picker implementations. Defaults toNone.
Raises:
NoImplementationFoundException: Raise when no implementation is found from the list of preferencesNoImplementationFoundException: Raise when no implementation is found for the current platform
Returns:
BaseFileDialog: File picker class.
CrossFileDialog.open_file(title, start_dir, filter) -> str
Open a file selection dialog for selecting a file.
Args:
- 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[str | list[str] | dict[str, str]] | dict[str, str | list[str]], optional): The filter for file types to display. For an example, head to documentation the ofcrossfiledialog.utils.filter_processor.
Returns:
Optional[str]: The selected file's path.
Example: result = open_file(title="Select a file", start_dir="/path/to/starting/directory", filter="*.txt")
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"]})
- a single wildcard (e.g.:
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.
Getting Started
Install the following dependencies
- Python 3.12
- just
In Linux, run the following command:
just bootstrap
or:
python3.12 -m venv --system-site-packages .venv
source .venv/bin/activate
rm -rf poetry.lock
poetry install --no-root --with dev
Linting
In any platform, run the following command:
just lint
or:
python -m no_implicit_optional crossfiledialog
python -m black -q school
python -m ruff check crossfiledialog --fix
Attribution
Thank you so much to Maikel Wever and 3ricsonn for allowing their Github repository to be relicensed to LGPL 3.0 so that I can use this library in my own proprietary projects.
My deepest gratitude also goes to Benjamin Auquite for letting me use snippets of their code from a pull request they made to the Toga repository, and to Russell Keith-Magee (the owner of said repository) and Malcolm Smith for the advice regarding using BSD 3-Clause licensed code to an LGPL licensed codebase.
Thank you so much!
License
This software is licensed under the GNU LGPL 3.0.
Copyright (c) 2020-2025 Maikel Wever
Copyright (c) 2024-2025 whinee
Portions of this codebase, specifically crossfiledialog/file_pickers/win32.py, are derived from Toga, which is licensed under the BSD 3-Clause License.
Copyright (c) 2014 Russell Keith-Magee.
See LICENSE.md for full details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file whines_crossfiledialog-1.0.0.tar.gz.
File metadata
- Download URL: whines_crossfiledialog-1.0.0.tar.gz
- Upload date:
- Size: 24.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.8 Linux/6.12.11-100.fc40.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43875a93656fe1f0355cace33acd76a955c7fe725debabe06c2241a08f311396
|
|
| MD5 |
f70302045be4b967f5aee4c3728b1cf5
|
|
| BLAKE2b-256 |
8e60f9f6520c7d3108589fab2a80bd213af01bac2b10a7b4a7ee871bbaf97f1f
|
File details
Details for the file whines_crossfiledialog-1.0.0-py3-none-any.whl.
File metadata
- Download URL: whines_crossfiledialog-1.0.0-py3-none-any.whl
- Upload date:
- Size: 23.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.8 Linux/6.12.11-100.fc40.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ceefbbdf776b45e4fb34a3b75686f3de7d0499aab2ef1a39177caabdda59e27
|
|
| MD5 |
fd82892e75e5245dcc7bfd56acdb1c5b
|
|
| BLAKE2b-256 |
ea4711feda313be7056991387b3ba726a218932f29ace2eefabf5aca6e0d7480
|