Interactive file selection prompts using Qt5.
Project description
pyqt5-file-dialogs
Interactive file selection prompts using Qt5.
Usage
import json
from pathlib import Path
from pyqt5filedialogs import get_open_filepath, get_save_filepath
def read_data():
"""
Load data from a JSON file selected by the user.
"""
filepath = get_open_filepath(caption="Select a JSON data file.")
with open(filepath, 'r') as f:
data = json.load(f)
return data
def export_config():
"""
Export a config `dict` object to a JSON file selected by the user.
"""
config = {
'preferences': {
'theme': 'light',
'font_size': 16,
'font_family': 'Roboto',
}
}
config_dir = Path.home().joinpath('.config', 'myapp')
if not config_dir.exists():
config_dir.mkdir(parents=True)
filepath = get_save_filepath(filter='JSON Files (*.json)')
with open(filepath, 'w') as f:
json.dump(config, f)
return filepath.stat().st_size
Installation
Install with pip.
$ pip install pyqt5filedialogs
Dependencies
PySide2
- Qt5 bindings for Python.
License
This project is licensed under the MIT license.
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
Close
Hashes for pyqt5_file_dialogs-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 017c4c5efbe8fda351a8fca328b9b418d18cb0759125e13c77250706216e2a15 |
|
MD5 | 7158757383edaf1381518cb6d9028854 |
|
BLAKE2b-256 | 70b424cf715a3e96425dd37b118016d4a6fd7bb9b08c6b46e525f35b36fcc009 |