file_path_widget
_file_path_widget
¶
Path input with browse button and validation indicator.
Classes:
| Name | Description |
|---|---|
FXFilePathWidget |
A line edit with integrated browse button for file/folder selection. |
Classes¶
FXFilePathWidget
¶
FXFilePathWidget(
parent: Optional[QWidget] = None,
mode: str = "file",
placeholder: str = "Select path...",
file_filter: str = "All Files (*)",
default_path: Optional[str] = None,
validate: bool = True,
)
Bases: FXThemeAware, QWidget
flowchart TD
fxgui.fxwidgets._file_path_widget.FXFilePathWidget[FXFilePathWidget]
fxgui.fxstyle.FXThemeAware[FXThemeAware]
fxgui.fxstyle.FXThemeAware --> fxgui.fxwidgets._file_path_widget.FXFilePathWidget
click fxgui.fxwidgets._file_path_widget.FXFilePathWidget href "" "fxgui.fxwidgets._file_path_widget.FXFilePathWidget"
click fxgui.fxstyle.FXThemeAware href "" "fxgui.fxstyle.FXThemeAware"
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 |
|---|---|---|---|
|
Optional[QWidget]
|
Parent widget. |
None
|
|
str
|
Selection mode ('file', 'files', 'folder', 'save'). |
'file'
|
|
str
|
Placeholder text. |
'Select path...'
|
|
str
|
File filter for file dialogs (e.g., "Images (.png .jpg)"). |
'All Files (*)'
|
|
Optional[str]
|
Default path for the file dialog. |
None
|
|
bool
|
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 |
Clear the path input. |
dragEnterEvent |
Handle drag enter for file drops. |
dropEvent |
Handle file drop. |
get_path |
Return the current path. |
is_valid |
Return whether the current path is valid. |
set_file_filter |
Set the file filter. |
set_mode |
Set the selection mode. |
set_path |
Set the path. |
Attributes:
| Name | Type | Description |
|---|---|---|
path |
str
|
Return the current path. |