File Path Widget¶
A widget for selecting file or folder paths with a browse button and path validation.
Preview
FXFilePathWidget
¶
Bases: ,
A line edit with integrated browse button for file/folder selection.
This widget provides: - File or folder mode selection - Drag & drop support - Path validation indicator - Browse button with file dialog
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
Parent widget. |
None
|
|
|
Selection mode ('file', 'files', 'folder', 'save'). |
'file'
|
|
|
Placeholder text. |
'Select path...'
|
|
|
File filter for file dialogs (e.g., "Images (*.png *.jpg)"). |
'All Files (*)'
|
|
|
Default path for the file dialog. |
None
|
|
|
Whether to show validation indicator. |
True
|
Signals
path_changed: Emitted when the path changes. path_valid: Emitted with True/False when validation state changes.
Examples:
>>> path_widget = FXFilePathWidget(mode='file', file_filter="Python (*.py)")
>>> path_widget.path_changed.connect(lambda p: print(f"Path: {p}"))
>>>
>>> # Folder mode
>>> folder_widget = FXFilePathWidget(mode='folder')
Methods:
| Name | Description |
|---|---|
|
Clear the path input. |
|
Handle drag enter for file drops. |
|
Handle file drop. |
|
Return the current path. |
|
Return whether the current path is valid. |
|
Set the file filter. |
|
Set the selection mode. |
|
Set the path. |
Attributes:
| Name | Type | Description |
|---|---|---|
|
|
Return the current path. |
set_file_filter
¶
Set the file filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
File filter string (e.g., "Images (*.png *.jpg)"). |
required |