Skip to content

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
parent
Optional[QWidget]

Parent widget.

None
mode
str

Selection mode ('file', 'files', 'folder', 'save').

'file'
placeholder
str

Placeholder text.

'Select path...'
file_filter
str

File filter for file dialogs (e.g., "Images (.png .jpg)").

'All Files (*)'
default_path
Optional[str]

Default path for the file dialog.

None
validate
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.

Attributes
path property writable
path: str

Return the current path.

Functions
clear
clear() -> None

Clear the path input.

dragEnterEvent
dragEnterEvent(event) -> None

Handle drag enter for file drops.

dropEvent
dropEvent(event) -> None

Handle file drop.

get_path
get_path() -> str

Return the current path.

is_valid
is_valid() -> bool

Return whether the current path is valid.

set_file_filter
set_file_filter(filter_str: str) -> None

Set the file filter.

Parameters:

Name Type Description Default
filter_str str

File filter string (e.g., "Images (.png .jpg)").

required
set_mode
set_mode(mode: str) -> None

Set the selection mode.

Parameters:

Name Type Description Default
mode str

Selection mode ('file', 'files', 'folder', 'save').

required
set_path
set_path(path: str) -> None

Set the path.

Parameters:

Name Type Description Default
path str

The file or folder path.

required