A reusable PyQt6 widget for selecting input/output paths, with four file/folder I/O modes, drag-and-drop, validation and auto-sync.
Project description
fry-qt6-io-widget
A reusable PyQt6 widget for picking input and output paths.
Four I/O modes out of the box:
| Mode | Input | Output | Example use case |
|---|---|---|---|
| A | Folder | Folder | Batch image processing |
| B | Folder | File | Aggregate a directory into one report |
| C | File | Folder | Extract / decompose an archive |
| D | File | File | One-shot conversion (md → html) |
Built-in features:
- Drag-and-drop a file or folder onto the input box
- Live path validity check (✓ exists / ○ will be created / ✗ invalid)
- Auto-sync: output path is generated from input path (postfix + optional timestamp)
- Safe browse-dialog fallback when a typed path no longer exists
- Opens the input/output location in the OS file manager
get_params_dict()/load_params_dict()for trivial persistence- Ships as a
QWidget— wrap it in aQDockWidgetyourself if you need that (see examples/example_dock_wrapper.py)
Install
pip install fry-qt6-io-widget
Requires Python 3.8+, PyQt6 ≥ 6.2, and QtAwesome ≥ 1.2.
Quick start
import sys
from PyQt6.QtWidgets import QApplication, QMainWindow
from fry_qt6_io_widget import FryIOWidget, IOMode
app = QApplication(sys.argv)
win = QMainWindow()
widget = FryIOWidget(mode=IOMode.FOLDER_TO_FOLDER)
win.setCentralWidget(widget)
widget.input_path_changed.connect(lambda p: print("in:", p))
widget.output_path_changed.connect(lambda p: print("out:", p))
win.show()
sys.exit(app.exec())
Pick a mode
FryIOWidget(mode=IOMode.FOLDER_TO_FOLDER) # A
FryIOWidget(mode=IOMode.FOLDER_TO_FILE) # B
FryIOWidget(mode=IOMode.FILE_TO_FOLDER) # C
FryIOWidget(mode=IOMode.FILE_TO_FILE) # D
Or switch at runtime:
widget.set_mode(IOMode.FILE_TO_FILE)
Use it as a dock
The package intentionally ships only a QWidget. Wrapping it in a dock
is three lines:
from PyQt6.QtWidgets import QDockWidget
from PyQt6.QtCore import Qt
dock = QDockWidget("输入输出", main_window)
dock.setWidget(FryIOWidget(mode=IOMode.FOLDER_TO_FOLDER))
main_window.addDockWidget(Qt.DockWidgetArea.LeftDockWidgetArea, dock)
A complete runnable example is in examples/example_dock_wrapper.py.
Useful options
FryIOWidget(
mode=IOMode.FOLDER_TO_FILE,
output_path_postfix="_report", # appended to the auto-generated output
output_use_timestamp=True, # also append HHMMSS_mmm
input_file_filter="Images (*.png *.jpg);;All (*)",
output_file_filter="CSV (*.csv)",
default_output_extension=".csv", # used in modes B and D
)
Helpful methods
widget.get_input_path() # -> str
widget.get_output_path() # -> str
widget.set_input_path("/some/path")
widget.set_output_path("/elsewhere")
widget.get_params_dict() # serialise current state
widget.load_params_dict(params) # restore it
widget.create_output_folder_if_needed() # mkdir -p for the output directory
widget.compute_auto_output_path("/foo") # preview what auto-sync would generate
Signals
| Signal | Payload | When |
|---|---|---|
input_path_changed |
str |
input text changes |
output_path_changed |
str |
output text changes |
Examples
Five runnable examples are in examples/:
example_a_folder_to_folder.py— mode Aexample_b_folder_to_file.py— mode Bexample_c_file_to_folder.py— mode Cexample_d_file_to_file.py— mode Dexample_mode_switcher.py— switch modes via comboboxexample_dock_wrapper.py— wrap into aQDockWidget
Run any of them:
python examples/example_a_folder_to_folder.py
Core concepts
For internals (auto-sync rules, path-validity states, how each mode re-uses the same UI), see docs/CORE_CONCEPTS.md.
Development
git clone https://gitlab.com/fanrenyi33/fry_python_lib_d130_fry_qt6_io_widget.git
cd fry_python_lib_d130_fry_qt6_io_widget
pip install -e ".[dev]"
pytest
To build distributions:
python -m build
# dist/fry_qt6_io_widget-0.1.4-py3-none-any.whl
# dist/fry_qt6_io_widget-0.1.4.tar.gz
License
MIT — see LICENSE.
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
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 fry_qt6_io_widget-0.1.4.tar.gz.
File metadata
- Download URL: fry_qt6_io_widget-0.1.4.tar.gz
- Upload date:
- Size: 35.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
361913076e9082166873d5f25f5f62450a04c9ca66e29f652e9bccd7a83fcee7
|
|
| MD5 |
0e6dd6bbed68463cbc8e92d4115fdddb
|
|
| BLAKE2b-256 |
a11f9fbf72aef797ae8e6e67f8e4cc3e6abbc614933ebf70f6ccaef6ae28399a
|
File details
Details for the file fry_qt6_io_widget-0.1.4-py3-none-any.whl.
File metadata
- Download URL: fry_qt6_io_widget-0.1.4-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0f398a05ebdd37a526ab7c42c8738632bf7e79e06fa629ea71fb10230578e49
|
|
| MD5 |
5c59a3b1b2a38467bc5b766acbb83301
|
|
| BLAKE2b-256 |
1648161280a3875e82d12ec457d0bf83d6eb96ccaa5852ffd3dd89bed7f5b2c5
|