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)
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"]}
)
- a single wildcard (e.g.:
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"]}
)
- 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.
Licence
Licensed under the GNU GPL 3.0
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
Built Distribution
File details
Details for the file crossfiledialog-0.2.0.tar.gz
.
File metadata
- Download URL: crossfiledialog-0.2.0.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4d085a00b2cdbd5fd99543c0876080e18e8e5465ff13bf968b3b7cf3ade9359 |
|
MD5 | 7a1cec06586008d3516a55dba0efea38 |
|
BLAKE2b-256 | e6a29127e5db23baab17c0c0755de7f56357bb2dfcf50f43072129f8c3a55048 |
File details
Details for the file crossfiledialog-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: crossfiledialog-0.2.0-py3-none-any.whl
- Upload date:
- Size: 20.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68d96e9bf0f266425139bcda778b405a5c581787f04ce1f7c491f2f8574b619d |
|
MD5 | caad5873e98b0c4432b75dadb4d48234 |
|
BLAKE2b-256 | fb7d59d857ee2c95184cd990814f519714b3464beb345da1c2f6da3cce893f32 |