misc.py

No documentation

class FileFinder

Description

File selection element with text field and browse button.
Displays selected file path and allows browsing filesystem via dialog.
Supports file filtering and custom icons.

Attributes
_properties: Dict[str, Dict[str, Any]] = {**UIElement._properties, 'file_path': {'name': 'file path', 'key': 'file_path', 'type': str, 'editable': True, 'description': 'Currently selected file path.'}, 'file_filter': {'name': 'file filter', 'key': 'file_filter', 'type': List[str], 'editable': False, 'description': 'List of extensions to filter (e.g., [".png", ".jpg"]).'}, 'dialog_title': {'name': 'dialog title', 'key': 'dialog_title', 'type': str, 'editable': True, 'description': 'Title of the file dialog window.'}, 'button_text': {'name': 'button text', 'key': 'button_text', 'type': str, 'editable': True, 'description': 'Text on the browse button.'}, 'show_icon': {'name': 'show icon', 'key': 'show_icon', 'type': bool, 'editable': True, 'description': 'Whether to display a file icon.'}}
Methods
def __init__(self: Any, x: int, y: int, width: int, height: int, file_path: str = '', file_filter: Optional[List[str]] = None, dialog_title: str = 'Select File', button_text: str = 'Browse...', show_icon: bool = True, icon_path: Optional[str] = None, pivot: Tuple[float, float] = (0, 0), theme: Optional[ThemeType] = None, element_id: Optional[str] = None) -> None
Initialize a file finder widget.

Args:
   x, y: Position (before anchor).
   width, height: Dimensions.
   file_path: Initial file path.
   file_filter: List of allowed extensions (e.g., [".txt", ".png"]).
   dialog_title: Title of the file dialog.
   button_text: Text on the browse button.
   show_icon: Display a file icon.
   icon_path: Path to a custom icon image.
   pivot: Anchor point.
   theme: Theme to apply.
   element_id: Custom ID.
def _get_init_args(self: Any) -> Dict[str, Any]
No documentation
def _check_tkinter(self: Any) -> bool
No documentation
def _create_child_elements(self: Any) -> None
No documentation
def _get_default_icon(self: Any) -> pygame.Surface
No documentation
def set_file_path(self: Any, path: str) -> None
Set the current file path and update the text box.
def _update_icon(self: Any) -> None
No documentation
def _open_file_dialog(self: Any) -> None
No documentation
def _open_tkinter_dialog(self: Any) -> None
No documentation
def _open_simple_dialog(self: Any) -> None
No documentation
def _get_initial_directory(self: Any) -> Optional[str]
No documentation
def set_on_file_selected(self: Any, callback: Callable[[str], None]) -> None
Register a callback for when a file is selected.
def get_file_path(self: Any) -> str
Return the current file path.
def update(self: Any, dt: float, inputState: InputState) -> None
No documentation
def render(self: Any, renderer: Renderer) -> None
No documentation
Back to Ui Module