### Install fluentflet from source Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md These commands clone the Fluent Flet repository from GitHub, navigate into the project directory, and then install it locally using the setup script. This method is useful for developers who want to access the latest unreleased code or contribute to the project. ```bash git clone https://github.com/Bbalduzz/fluentflet.git cd fluentflet py setup.py install ``` -------------------------------- ### Basic TreeView Component Setup (Python) Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Demonstrates the basic setup of the TreeView component using a dictionary for data and a default DictTreeViewModel. Includes an example of a right-click handler. ```python from fluentflet.components import TreeView, DictTreeViewModel # Basic tree data = { "Root": { "Item1": 1.0, "Item2": { "SubItem1": 2.1, "SubItem2": 2.2 } } } tree = TreeView( data=data, model=DictTreeViewModel(), on_right_click=lambda item: print(f"Right clicked: {item.label}") ) ``` -------------------------------- ### FluentWindow Constructor Parameters and Examples Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Defines the parameters for initializing a FluentWindow, including options for navigation items, colors, and layout. It also provides example structures for navigation items and color overrides. ```python [ { "icon": FluentIcons.HOME, # Icon enum "label": "Home", # Display text "route": "/", # Optional route } ] ``` ```python { "nav_bg": "#1F1F1F", "content_bg": "#282828", "title_bar_bg": "#1F1F1F", "icon_color": "white", "text_color": "white" } ``` -------------------------------- ### Install fluentflet using pip Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md This command installs the fluentflet library from the Python Package Index (PyPI). Ensure you have pip installed and configured correctly. ```bash pip install fluentflet ``` -------------------------------- ### FluentWindow Example Usage Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Demonstrates how to initialize and use the FluentWindow class in a Flet application. It showcases setting up navigation items, defining views with route decorators, and performing programmatic navigation. ```python def main(page: ft.Page): window = FluentWindow( page, navigation_items=[ {"icon": FluentIcons.HOME, "label": "Home", "route": "/"}, {"icon": FluentIcons.PEOPLE, "label": "Users", "route": "/users"} ] ) @window.route("/") def home_view(): return ft.Column([ ft.Text("Welcome!", size=32), Button("View Users", on_click=lambda _: window.navigate("/users")) ]) @window.route("/users/:user_id", is_template=True) def user_profile(user_id: str): return ft.Column([ ft.Text(f"User Profile: {user_id}") ]) window.navigate("/") ft.app(target=main) ``` -------------------------------- ### Tooltip Component Examples in Python Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Shows how to implement tooltips for interactive elements using the ToolTip component. Examples include basic tooltips attached to buttons and custom-styled tooltips with specific text styles and background colors. The `content` parameter defines the target element for the tooltip. ```python import fluentflet as ft from fluentflet.components import ToolTip, Button # Basic tooltip button = Button("Hover me") tooltip = ToolTip( message="This is a tooltip", content=button ) # Custom styled tooltip tooltip = ToolTip( message="Custom tooltip", content=ft.Text("Hover for info"), text_style=ft.TextStyle( size=14, weight=ft.FontWeight.BOLD ), bgcolor="#333333", border_radius=8 ) ``` -------------------------------- ### TreeView Component Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Documentation for the TreeView component, including its constructor parameters, methods, and example usage. ```APIDOC ## TreeView ### Description Main tree view component with drag-drop support. ### Inheritance Inherits from `ft.Column`. ### Constructor Parameters - `data` (dict) - Required. Source data. - `model` (Optional[TreeViewAbstractModel]) - Optional. Data model, defaults to `DictTreeViewModel()`. - `on_right_click` (Optional[Callable]) - Optional. Right-click handler. - `is_dark_mode` (bool) - Optional. Theme mode, defaults to `True`. ### Methods - `handle_item_drop(src_id: str, target_id: str)`: Handle item reordering. ### Example Usage ```python from fluentflet.components import TreeView, DictTreeViewModel # Basic tree data = { "Root": { "Item1": 1.0, "Item2": { "SubItem1": 2.1, "SubItem2": 2.2 } } } tree = TreeView( data=data, model=DictTreeViewModel(), on_right_click=lambda item: print(f"Right clicked: {item.label}") ) # Custom model tree class MyModel(TreeViewAbstractModel[List[Dict]]): def process_data(self): for item in self.raw_data: self.items.append(TreeItemData( id=str(item["id"]), label=item["name"], value=item["data"] )) tree = TreeView( data=my_data, model=MyModel() ) ``` ``` -------------------------------- ### FluentFlet Dropdown with String and Control Options Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Demonstrates how to create a Dropdown component using fluentflet. It shows examples with simple string options and custom Flet controls as options, along with specifying callbacks and maximum width. ```python from fluentflet.components import Dropdown import flet as ft # Simple string options dropdown = Dropdown( options=["Option 1", "Option 2", "Option 3"], on_select=lambda value: print(f"Selected: {value}") ) # Custom control options dropdown_with_icons = Dropdown( options=[ ft.Row([ ft.Icon(ft.icons.SETTINGS), ft.Text("Settings") ]), ft.Row([ ft.Icon(ft.icons.PERSON), ft.Text("Profile") ]) ], max_width=200 ) ``` -------------------------------- ### Create and Show Dialogs in Python Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Provides examples of creating and displaying modal dialogs using the Fluentflet Dialog component in Python. Supports custom titles, content (including Flet controls), and action buttons. ```python import flet as ft from fluentflet.components import Dialog, Button, ButtonVariant # Simple dialog dialog = Dialog( title="Confirm Action", content=ft.Text("Are you sure you want to proceed?") ) # Custom dialog with multiple actions custom_dialog = Dialog( title="Save Changes", content=ft.Column([ ft.Text("Save current changes?"), ft.TextField(label="Comment") ]), actions=[ Button("Save", variant=ButtonVariant.ACCENT), Button("Don't Save"), Button("Cancel") ] ) # Show dialog # Assuming 'page' is an instance of ft.Page # page.overlay.append(dialog) # dialog.show() ``` -------------------------------- ### FluentFlet FluentWindow Navigation and State Management (Python) Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Illustrates the setup of FluentWindow for managing navigation and application state. Includes defining navigation items, setting navigation types (STANDARD, OVERLAY), and implementing a custom state management class using FluentState. Requires fluentflet. ```python from fluentflet import FluentWindow, NavigationType, FluentIcons from fluentflet.window.fluent_state import FluentState from typing import Any, Callable # Mock Page object for demonstration class MockPage: pass page = MockPage() # Replace with actual Flet page object # Example NavigationType Enum definition class NavigationType: STANDARD = "standard" OVERLAY = "overlay" # Mock FluentIcons class FluentIcons: HOME = "home_icon" SETTINGS = "settings_icon" # Mock FluentWindow class for demonstration class MockFluentWindow: def __init__(self, page, nav_type, navigation_items): self.page = page self.nav_type = nav_type self.navigation_items = navigation_items self.state = None print(f"FluentWindow initialized with nav_type: {nav_type}") # Example Usage: window = MockFluentWindow( page=page, nav_type=NavigationType.OVERLAY, navigation_items=[ {"icon": FluentIcons.HOME, "label": "Home", "route": "/home"}, {"icon": FluentIcons.SETTINGS, "label": "Settings", "route": "/settings"} ] ) # Example FluentState implementation class AppState(FluentState): def _load_initial_state(self): self._state = { "theme": "light", "selected_user": None } def set_theme(self, theme: str): self.set("theme", theme, persist=True) # Instantiate and assign state window.state = AppState() window.state.subscribe("theme", lambda t: print(f"Theme changed: {t}")) # Example of setting state window.state.set_theme("dark") print(f"Current theme: {window.state.get('theme')}") print(f"Selected user: {window.state.get('selected_user', 'Not selected')}") ``` -------------------------------- ### Create and Configure TextBox Components Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Shows how to implement TextBox components for text input. Examples include basic text entry, password fields, and text boxes with prefixes and suffixes. It also demonstrates adding action buttons to the textbox. ```python from fluentflet.components import TextBox from fluentflet.utils import FluentIcons # Basic textbox textbox = TextBox( placeholder="Enter text", width=300 ) # Password textbox password = TextBox( placeholder="Password", password=True ) # TextBox with prefix and suffix url_input = TextBox( placeholder="Enter domain name", prefix="https://", suffix=".com", width=300 ) ``` -------------------------------- ### FluentFlet Expander with Text and Custom Header Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Illustrates the creation of an Expander component from fluentflet. Examples include a basic text-based expander and one with a complex custom header, demonstrating collapsible content sections. ```python from fluentflet.components import Expander import flet as ft # Simple text expander expander = Expander( header="Click to Expand", content=ft.Text("Expanded content here"), expand=False ) # Complex expander with custom header expander = Expander( header=ft.Row([ ft.Icon(ft.icons.SETTINGS), ft.Text("Advanced Settings") ]), content=ft.Column([ ft.TextField(label="Setting 1"), ft.TextField(label="Setting 2") ]) ) ``` -------------------------------- ### FluentFlet ProgressRing for Indeterminate and Determinate States Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Demonstrates the use of the ProgressRing component from fluentflet. Examples show how to create an indeterminate progress indicator and a determinate one with a specified value, along with custom styling options. ```python from fluentflet.components import ProgressRing # Indeterminate progress loading = ProgressRing() # Determinate progress progress = ProgressRing(value=0.75) # Custom styled progress custom = ProgressRing( value=0.5, stroke_width=5, width=100, height=100 ) ``` -------------------------------- ### Toggle Component Examples in Python Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Illustrates the usage of the Toggle component for creating switchable elements. It covers simple toggles, toggles with different ON/OFF labels, and custom-styled toggles. The `on_change` callback is used to handle state changes. ```python from fluentflet.components import Toggle # Simple toggle toggle = Toggle( value=False, label="Enable feature", on_change=lambda state: print(f"Toggled: {state}") ) # Toggle with different labels toggle = Toggle( value=True, label={ "on_content": "Enabled", "off_content": "Disabled" } ) # Custom styled toggle toggle = Toggle( label="Custom toggle", label_style={ "size": 16, "weight": "bold" }, width=50, height=25 ) ``` -------------------------------- ### FluentFlet ListItem with Simple and Complex Content Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Shows how to implement a ListItem component using fluentflet. Examples cover creating simple text list items and more complex ones with embedded controls like icons and columns, including selection functionality. ```python from fluentflet.components import ListItem import flet as ft # Simple list item item = ListItem( content=ft.Text("List Item 1"), on_click=lambda _: print("Clicked") ) # Complex list item item = ListItem( content=ft.Row([ ft.Icon(ft.icons.PERSON), ft.Column([ ft.Text("John Doe"), ft.Text("john@example.com", size=12) ]) ]), selected=True ) # List of items items_list = ft.ListView( controls=[ ListItem(content=ft.Text(f"Item {i}")) for i in range(5) ] ) ``` -------------------------------- ### DictTreeViewModel Usage in Python Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Shows how to use the DictTreeViewModel to represent hierarchical data stored in a Python dictionary. The example demonstrates assigning raw dictionary data to the model and how it can be processed for tree view display. ```python from fluentflet.components import DictTreeViewModel data = { "Root": { "Child1": { "GrandChild1": 1.1, "GrandChild2": 1.2 }, "Child2": 2.0 } } model = DictTreeViewModel() model.raw_data = data ``` -------------------------------- ### FluentWindow Navigation Methods Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Explains the methods for managing navigation within a FluentWindow. `navigate` allows programmatic redirection, while `add_route` and the `@route` decorator enable route registration. ```python def navigate(self, route: str, **params): """Navigate to route with optional parameters Parameters: - route: Route path - **params: Route parameters """ @route("/path") def view_builder(): """Route decorator for registering views""" return ft.Column([...]) def add_route(self, route: str, view_builder: Callable[..., ft.Control], is_template: bool = False): """Register route manually""" ``` -------------------------------- ### Create and Configure Buttons in Python Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Demonstrates how to create and configure different types of buttons using the Fluentflet Button component. Supports text content, icon content, and toggle functionality with various styling variants. ```python from fluentflet.components import Button, ButtonVariant from fluentflet.utils import FluentIcon, FluentIcons # Text button basic_button = Button( "Click Me", variant=ButtonVariant.DEFAULT, on_click=lambda e: print("Clicked!") ) # Icon button with accent icon_button = Button( content=FluentIcon(FluentIcons.ADD), variant=ButtonVariant.ACCENT ) # Toggle button toggle = Button( "Toggle Me", variant=ButtonVariant.TOGGLE, on_click=lambda e: print(f"Toggled: {toggle.is_toggled}") ) ``` -------------------------------- ### FluentWindow and State Management Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Manages window appearance, navigation, routing, and state for Fluent Design applications. ```APIDOC ## FluentWindow and State Management ### Purpose Implements a window manager with navigation, routing, and state management following Fluent Design principles. ### NavigationType (Enum) Enum for controlling navigation layout: ```python class NavigationType(Enum): STANDARD = auto() # Original layout that pushes content OVERLAY = auto() # Navigation overlays the content ``` ### Classes #### FluentState **Purpose**: State management for FluentWindow applications ```python class FluentState: """Manages persistent and ephemeral application state""" def set(self, key: str, value: any, persist: bool = False): """Set state value Parameters: - key: State key - value: State value - persist: If True, saves to session storage """ def get(self, key: str, default=None) -> any: """Get state value""" def subscribe(self, key: str, callback: callable): """Subscribe to state changes""" ``` **Example Usage**: ```python class AppState(FluentState): def _load_initial_state(self): self._state = { "theme": "light", "selected_user": None } def set_theme(self, theme: str): self.set("theme", theme, persist=True) window.state = AppState() window.state.subscribe("theme", lambda t: print(f"Theme changed: {t}")) ``` #### FluentWindow **Purpose**: Main window manager implementing navigation and routing. **Example Usage**: ```python from fluentflet import FluentWindow, NavigationType window = FluentWindow( page=page, nav_type=NavigationType.OVERLAY, navigation_items=[ {"icon": FluentIcons.HOME, "label": "Home", "route": "/home"}, {"icon": FluentIcons.SETTINGS, "label": "Settings", "route": "/settings"} ] ) ``` ``` -------------------------------- ### FluentFlet Toaster and Toast Usage (Python) Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Demonstrates how to use the Toaster component to display simple, actionable, and custom toasts with various severity levels and styling options. Requires the fluentflet library. ```python from fluentflet.components import Toast, Toaster, ToastSeverity, ToastVariant, ToastActionType import flet as ft def main(page: ft.Page): # Create toaster toaster = Toaster( page=page, position="top-right", default_toast_duration=5 ) # Show simple toast toaster.show_toast( title="Success!", message="Operation completed", severity=ToastSeverity.SUCCESS ) # Show toast with action toaster.show_toast( title="Warning", message="Connection lost", severity=ToastSeverity.WARNING, action_type="default", action_text="Retry", on_action=lambda: print("Retrying...") ) # Show custom toast custom_toast = Toast( title="Custom Toast", message="With custom styling", severity=ToastSeverity.INFORMATIONAL, variant=ToastVariant.MULTI_LINE, action_type=ToastActionType.HYPERLINK, action_text="Learn More", action_url="https://example.com" ) toaster.show_toast(toast=custom_toast) ft.app(target=main) ``` -------------------------------- ### Create and Configure Slider Components Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Illustrates the creation of Slider components for selecting values within a range. It covers setting minimum and maximum values, initial values, orientation (horizontal/vertical), and handling value changes. This is suitable for scenarios requiring numerical input or adjustments. ```python from fluentflet.components import Slider, SliderOrientation # Horizontal slider slider = Slider( value=50, min=0, max=100, on_change=lambda e: print(f"Value: {e.current_value}") ) # Vertical slider vertical_slider = Slider( value=0.5, min=0, max=1, orientation=SliderOrientation.VERTICAL, size=150 ) # Custom range slider custom = Slider( value=-50, min=-100, max=100, disabled=False ) ``` -------------------------------- ### Toast Component Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Documentation for the Toast component, which provides individual toast notifications with Fluent Design styling. ```APIDOC ## Toast ### Description Individual toast notification with Fluent Design styling. ### Inheritance Inherits from `ft.Container`. ### Constructor Parameters - `title` (Optional[str]) - Optional. Toast title text. - `message` (Optional[str]) - Optional. Toast message text. - `severity` (ToastSeverity | str) - Optional. Toast style, defaults to `ToastSeverity.INFORMATIONAL`. - `variant` (ToastVariant | str) - Optional. Layout style, defaults to `ToastVariant.SINGLE_LINE`. - `action_type` (ToastActionType | str) - Optional. Action button type, defaults to `ToastActionType.NONE`. - `action_text` (Optional[str]) - Optional. Action button text. - `action_url` (Optional[str]) - Optional. URL for hyperlink action. - `on_action` (Optional[Callable]) - Optional. Action click handler. - `position` (ToastPosition | str) - Optional. Toast position, defaults to `ToastPosition.TOP_RIGHT`. - `**kwargs` - Additional container properties. ``` -------------------------------- ### FluentFlet Page Blur Effect and Drop Support (Python) Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Shows how to extend Flet's Page object with properties to control window blur effects on Windows and to enable file drag-and-drop functionality. Callbacks can be defined for various drag events. Requires fluentflet. ```python from typing import Optional, Callable, List, Tuple import flet as ft # Assuming Page class is extended by fluentflet # class Page: # def __init__(self, *args, **kwargs): # super().__init__(*args, **kwargs) # self._blur = False # self._accepts_drops = False # @property # def blur_effect(self) -> bool: # """Controls window blur effect on Windows""" # return self._blur # @blur_effect.setter # def blur_effect(self, value: bool): # # Only available on Windows # # Enables/disables acrylic blur effect # self._blur = value # @property # def accepts_drops(self) -> bool: # """Controls file drop acceptance""" # return self._accepts_drops # @accepts_drops.setter # def accepts_drops(self, value: bool): # # Enables/disables file drop handling # self._accepts_drops = value # def enable_drag_and_drop( # self, # files_callback: Optional[Callable[[List[str]], None]] = None, # drag_enter_callback: Optional[Callable[[Tuple[int, int]], None]] = None, # drag_over_callback: Optional[Callable[[Tuple[int, int]], None]] = None, # drag_leave_callback: Optional[Callable[[], None]] = None # ): # """Enable file drag-drop functionality # Parameters: # - files_callback: Called with list of dropped file paths # - drag_enter_callback: Called with (x,y) when drag enters window # - drag_over_callback: Called with (x,y) while dragging over window # - drag_leave_callback: Called when drag leaves window # """ # # Placeholder for actual implementation # pass # Mock Page object for demonstration class MockPage: def __init__(self, *args, **kwargs): self._blur = False self._accepts_drops = False @property def blur_effect(self) -> bool: return self._blur @blur_effect.setter def blur_effect(self, value: bool): self._blur = value @property def accepts_drops(self) -> bool: return self._accepts_drops @accepts_drops.setter def accepts_drops(self, value: bool): self._accepts_drops = value def enable_drag_and_drop( self, files_callback: Optional[Callable[[List[str]], None]] = None, drag_enter_callback: Optional[Callable[[Tuple[int, int]], None]] = None, drag_over_callback: Optional[Callable[[Tuple[int, int]], None]] = None, drag_leave_callback: Optional[Callable[[], None]] = None ): print("Drag and drop enabled with callbacks.") # Example Usage: def on_files_dropped(files): print("Files dropped:", files) def on_drag_enter(point): print(f"Drag entered at {point}") # Assuming 'page' is an instance of the extended Page class page = MockPage() # Replace with actual Flet page object page.accepts_drops = True page.enable_drag_and_drop( files_callback=on_files_dropped, drag_enter_callback=on_drag_enter ) # To enable blur effect (Windows only): # page.blur_effect = True ``` -------------------------------- ### TreeItemData Initialization in Python Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Demonstrates the creation of tree data items using the TreeItemData class. This includes setting item IDs, labels, and defining nested child items. It serves as the fundamental building block for creating tree structures. ```python from fluentflet.components import TreeItemData item = TreeItemData( id="root", label="Root Item", children=[ TreeItemData(id="child1", label="Child 1"), TreeItemData(id="child2", label="Child 2") ] ) ``` -------------------------------- ### Create and Configure Checkboxes in Python Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Shows how to create and configure Checkbox components with Fluent Design styling in Python. Supports basic checkboxes, tri-state checkboxes, and disabled states, with an optional label and change callback. ```python from fluentflet.components import Checkbox, CheckState # Basic checkbox checkbox = Checkbox( label="Enable feature", on_change=lambda state: print(f"State: {state}") ) # Tri-state checkbox tristate = Checkbox( label="Select files", three_state=True, state=CheckState.INDETERMINATE ) # Disabled checkbox disabled = Checkbox( label="Unavailable option", disabled=True, state=CheckState.CHECKED ) ``` -------------------------------- ### Textbox with Actions in Python Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Demonstrates how to create a textbox with custom actions like search and clear. It utilizes the TextBox component and FluentIcons for UI elements. Actions are defined using lambda functions for click events. ```python from fluentflet.components import TextBox, FluentIcons textbox_with_actions = TextBox( placeholder="Search", width=400 ) textbox_with_actions.add_action( icon=FluentIcons.SEARCH, on_click=lambda _: print("Search clicked"), tooltip="Search" ) textbox_with_actions.add_action( icon=FluentIcons.DISMISS, on_click=lambda _: setattr(textbox_with_actions, 'value', ''), tooltip="Clear" ) ``` -------------------------------- ### Create and Configure Radio Buttons and Radio Groups Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Demonstrates how to create individual radio buttons and group them using RadioGroup. It shows how to set values, labels, disabled states, and handle selection changes. This snippet is useful for implementing choice selection in forms. ```python from fluentflet.components import Radio, RadioGroup import flet as ft # Single radio button radio = Radio( value="option1", label="Option 1", disabled=False ) # Radio group radio_group = RadioGroup( content=ft.Column([ Radio(value="small", label="Small"), Radio(value="medium", label="Medium"), Radio(value="large", label="Large") ]), value="medium", on_change=lambda value: print(f"Selected: {value}") ) ``` -------------------------------- ### Page Monkey Patches Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Extends Flet's Page class with properties and methods for blur effects and drag-and-drop file handling. ```APIDOC ## Page Monkey Patches ### Purpose Extends Flet's Page class with additional functionality for blur effects and drag-drop support. ### Added Page Properties #### page.`blur_effect` ```python @property def blur_effect(self) -> bool: """Controls window blur effect on Windows""" return self._blur @blur_effect.setter def blur_effect(self, value: bool): # Only available on Windows # Enables/disables acrylic blur effect ``` #### page.`accepts_drops` ```python @property def accepts_drops(self) -> bool: """Controls file drop acceptance""" return self._accepts_drops @accepts_drops.setter def accepts_drops(self, value: bool): # Enables/disables file drop handling ``` ### Added Page Methods #### enable_drag_and_drop ```python def enable_drag_and_drop( files_callback: Optional[Callable[[List[str]], None]] = None, drag_enter_callback: Optional[Callable[[Tuple[int, int]], None]] = None, drag_over_callback: Optional[Callable[[Tuple[int, int]], None]] = None, drag_leave_callback: Optional[Callable[[], None]] = None ): """Enable file drag-drop functionality Parameters: - files_callback: Called with list of dropped file paths - drag_enter_callback: Called with (x,y) when drag enters window - drag_over_callback: Called with (x,y) while dragging over window - drag_leave_callback: Called when drag leaves window """ ``` ### Example Usage ```python def on_files_dropped(files): print("Files dropped:", files) def on_drag_enter(point): print(f"Drag entered at {point}") page.accepts_drops = True page.enable_drag_and_drop( files_callback=on_files_dropped, drag_enter_callback=on_drag_enter ) ``` ``` -------------------------------- ### Toaster Component Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Documentation for the Toaster component, a manager for showing and hiding toast notifications. ```APIDOC ## Toaster ### Description Toast notification manager for showing/hiding toasts. ### Constructor Parameters - `page` (ft.Page) - Required. Flet page instance. - `expand` (bool) - Optional. Auto-expand toasts on hover, defaults to `False`. - `position` (ToastPosition | str) - Optional. Default position, defaults to `ToastPosition.TOP_RIGHT`. - `theme` (str) - Optional. Theme mode, defaults to `"dark"`. - `default_toast_duration` (int) - Optional. Default show duration in seconds, defaults to `3`. - `default_offset` (int) - Optional. Spacing from window edge, defaults to `20`. ### Methods #### show_toast Displays a toast notification. ```python def show_toast( self, title: Optional[str] = None, message: Optional[str] = None, severity: ToastSeverity | str = ToastSeverity.INFORMATIONAL, variant: ToastVariant | str = ToastVariant.SINGLE_LINE, action_type: ToastActionType | str = ToastActionType.NONE, action_text: Optional[str] = None, action_url: Optional[str] = None, on_action: Optional[Callable] = None, position: Optional[ToastPosition | str] = None, duration: int = 3, toast: Optional[Toast] = None, **kwargs ) -> None: ``` ``` -------------------------------- ### Dialog Component Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Provides a modal dialog overlay with Fluent Design styling, customizable with titles, content, and action buttons. ```APIDOC ## Dialog Component ### Description Implements a modal dialog overlay with Fluent Design styling, customizable with titles, content, and action buttons. ### Constructor Parameters - `title` (str): Dialog header text. Defaults to "Dialog Title". - `content` (Optional[ft.Control]): Main content area. Defaults to simple text if not provided. Can be any Flet control. - `actions` (Optional[List[Button]]): Bottom action buttons. Defaults to ["Action", "Close"] buttons if not provided. Close button is automatically included. ### Methods - `show()`: Displays the dialog. - Returns: None. Updates page overlay. - `close_dialog(e: Optional[ft.ControlEvent] = None)`: Hides and removes the dialog. - Returns: None. Removes from page overlay. ### Example Usage ```python from fluentflet.components import Dialog, Button, ButtonVariant # Simple dialog dialog = Dialog( title="Confirm Action", content=ft.Text("Are you sure you want to proceed?") ) # Custom dialog with multiple actions custom_dialog = Dialog( title="Save Changes", content=ft.Column([ ft.Text("Save current changes?"), ft.TextField(label="Comment") ]), actions=[ Button("Save", variant=ButtonVariant.ACCENT), Button("Don't Save"), Button("Cancel") ] ) # Show dialog page.overlay.append(dialog) dialog.show() ``` ``` -------------------------------- ### Button Component Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Allows for creating styled buttons with text or icons, supporting different variants and customization. ```APIDOC ## Button Component ### Description Creates styled buttons with text or icons, supporting different variants and customization. ### Constructor Parameters - `content` (Union[str, ft.Control]): Button content (text or control like icon). If string, creates Text control automatically. If control, uses directly. - `variant` (ButtonVariant): Button style variant. Defaults to `ButtonVariant.DEFAULT`. - `height` (int): Button height in pixels. Defaults to 35. - `custom_color` (Optional[str]): Optional color override. - `design_system` (FluentDesignSystem): Design system instance. - `is_dark_mode` (bool): Theme mode selection. Defaults to True. - `**kwargs`: Additional Flet button properties. ### Example Usage ```python from fluentflet.components import Button, ButtonVariant from fluentflet.utils import FluentIcon, FluentIcons # Text button basic_button = Button( "Click Me", variant=ButtonVariant.DEFAULT, on_click=lambda e: print("Clicked!") ) # Icon button with accent icon_button = Button( content=FluentIcon(FluentIcons.ADD), variant=ButtonVariant.ACCENT ) # Toggle button toggle = Button( "Toggle Me", variant=ButtonVariant.TOGGLE, on_click=lambda e: print(f"Toggled: {toggle.is_toggled}") ) ``` ``` -------------------------------- ### Toast System Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Provides a flexible and customizable toast notification system with various severity levels, variants, and actions. ```APIDOC ## Toast System ### Description The Toast system allows for displaying notifications to the user with different levels of importance, styling, and interactivity. ### Components - **Toaster**: Manages the creation and display of toasts. - **Toast**: Represents an individual toast notification. ### Toast Severity Levels - `ToastSeverity.SUCCESS` - `ToastSeverity.WARNING` - `ToastSeverity.DANGER` - `ToastSeverity.INFORMATIONAL` ### Toast Variants - `ToastVariant.SINGLE_LINE` - `ToastVariant.MULTI_LINE` ### Toast Action Types - `ToastActionType.DEFAULT` - `ToastActionType.HYPERLINK` ### Example Usage ```python from fluentflet.components import Toast, Toaster, ToastSeverity, ToastVariant, ToastActionType import flet as ft def main(page: ft.Page): toaster = Toaster( page=page, position="top-right", default_toast_duration=5 ) # Show simple toast toaster.show_toast( title="Success!", message="Operation completed", severity=ToastSeverity.SUCCESS ) # Show toast with action toaster.show_toast( title="Warning", message="Connection lost", severity=ToastSeverity.WARNING, action_type=ToastActionType.DEFAULT, action_text="Retry", on_action=lambda: print("Retrying...") ) # Show custom toast custom_toast = Toast( title="Custom Toast", message="With custom styling", severity=ToastSeverity.INFORMATIONAL, variant=ToastVariant.MULTI_LINE, action_type=ToastActionType.HYPERLINK, action_text="Learn More", action_url="https://example.com" ) toaster.show_toast(toast=custom_toast) ft.app(target=main) ``` ``` -------------------------------- ### show_toast Method Signature (Python) Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md The signature for the show_toast method of the Toaster class, outlining all available parameters for customizing and displaying a toast notification. ```python def show_toast( self, title: Optional[str] = None, message: Optional[str] = None, severity: ToastSeverity | str = ToastSeverity.INFORMATIONAL, variant: ToastVariant | str = ToastVariant.SINGLE_LINE, action_type: ToastActionType | str = ToastActionType.NONE, action_text: Optional[str] = None, action_url: Optional[str] = None, on_action: Optional[Callable] = None, position: Optional[ToastPosition | str] = None, duration: int = 3, toast: Optional[Toast] = None, **kwargs ) -> None ``` -------------------------------- ### Dropdown Component Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Implements a dropdown select control with Fluent Design styling, allowing users to choose from a list of options. ```APIDOC ## Dropdown Component ### Description Implements a dropdown select control with Fluent Design styling, allowing users to choose from a list of options. ### Attributes - `options` (List[Union[str, ft.Control]]): Available options. - `max_width` (int): Maximum width of the dropdown. - `selected_value` (str): Currently selected option. - `is_open` (bool): Dropdown expanded state. ``` -------------------------------- ### TreeView Data Initialization (Python) Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Initializes data for the TreeView component. The data is structured as a list of dictionaries, where each dictionary represents a node and can contain nested 'children'. ```python data = [ { "id": "1", "label": "Item 1", "children": [ { "id": "1.1", "label": "Subitem 1.1" } ] } ] model = JSONTreeViewModel() model.raw_data = data ``` -------------------------------- ### Custom TreeView Model Implementation (Python) Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Illustrates how to implement a custom model for the TreeView component by inheriting from TreeViewAbstractModel and overriding the process_data method to define custom data processing logic. ```python from fluentflet.components import TreeView, TreeViewAbstractModel, TreeItemData # Custom model tree class MyModel(TreeViewAbstractModel[List[Dict]]): def process_data(self): for item in self.raw_data: self.items.append(TreeItemData( id=str(item["id"]), label=item["name"], value=item["data"] )) tree = TreeView( data=my_data, model=MyModel() ) ``` -------------------------------- ### Toast Component Enums Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Enumerations for configuring the Toast component's behavior and appearance. ```APIDOC ## Toast Enums ### ToastPosition Represents the position of the toast notification on the screen. ```python class ToastPosition(Enum): TOP_LEFT = "top-left" TOP_RIGHT = "top-right" TOP_CENTER = "top-center" BOTTOM_LEFT = "bottom-left" BOTTOM_RIGHT = "bottom-right" BOTTOM_CENTER = "bottom-center" ``` ### ToastVariant Determines the layout style of the toast. ```python class ToastVariant(Enum): SINGLE_LINE = "single-line" # Compact single line toast MULTI_LINE = "multi-line" # Expanded multi-line toast ``` ### ToastSeverity Defines the visual style and severity level of the toast. ```python class ToastSeverity(Enum): INFORMATIONAL = "informational" # Blue info style SUCCESS = "success" # Green success style WARNING = "warning" # Yellow warning style CRITICAL = "critical" # Red error style ``` ### ToastActionType Specifies the type of action button displayed on the toast. ```python class ToastActionType(Enum): NONE = "none" # No action button HYPERLINK = "hyperlink" # Link style action DEFAULT = "default" # Button style action ``` ``` -------------------------------- ### Checkbox Component Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Implements a tri-state checkbox control with Fluent Design styling, allowing for unchecked, checked, and indeterminate states. ```APIDOC ## Checkbox Component ### Description Implements a tri-state checkbox control with Fluent Design styling, allowing for unchecked, checked, and indeterminate states. ### CheckState (Enum) Represents the state of the checkbox. - `UNCHECKED`: Box is empty. - `CHECKED`: Box has checkmark. - `INDETERMINATE`: Box has dash (mixed state). ### Constructor Parameters - `state` (CheckState): Initial state. Defaults to `CheckState.UNCHECKED`. - `label` (str): Optional label text. Defaults to "". - `size` (int): Size of the checkbox in pixels. Defaults to 20. - `on_change` (Callable[[CheckState], None]): State change callback. - `disabled` (bool): Initial disabled state. Defaults to False. - `three_state` (bool): Enable tri-state behavior. Defaults to False. - `design_system` (FluentDesignSystem): Design system instance. - `is_dark_mode` (bool): Theme mode selection. Defaults to True. - `**kwargs`: Additional container properties. ### Example Usage ```python from fluentflet.components import Checkbox, CheckState # Basic checkbox checkbox = Checkbox( label="Enable feature", on_change=lambda state: print(f"State: {state}") ) # Tri-state checkbox tristate = Checkbox( label="Select files", three_state=True, state=CheckState.INDETERMINATE ) # Disabled checkbox disabled = Checkbox( label="Unavailable option", disabled=True, state=CheckState.CHECKED ) ``` ``` -------------------------------- ### ButtonVariant Enum Definition Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Defines the different visual styles available for buttons in the fluentflet library. Each variant provides distinct styling for different user interaction needs. ```python class ButtonVariant(Enum): DEFAULT = "default" # Standard button styling ACCENT = "accent" # Primary action/emphasized styling HYPERLINK = "hyperlink" # Text-like button styling TOGGLE = "toggle" # Toggleable state button ``` -------------------------------- ### Define Checkbox States in Python Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Defines the possible states for a checkbox component using an Enum in Python. These states include UNCHECKED, CHECKED, and INDETERMINATE, allowing for tri-state checkbox functionality. ```python from enum import Enum class CheckState(Enum): UNCHECKED = "unchecked" # Box is empty CHECKED = "checked" # Box has checkmark INDETERMINATE = "indeterminate" # Box has dash (mixed state) ``` -------------------------------- ### ToastSeverity Enum Definition (Python) Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Defines the ToastSeverity enumeration for styling toast notifications based on their importance. Includes informational, success, warning, and critical styles. ```python class ToastSeverity(Enum): INFORMATIONAL = "informational" # Blue info style SUCCESS = "success" # Green success style WARNING = "warning" # Yellow warning style CRITICAL = "critical" # Red error style ``` -------------------------------- ### ToastPosition Enum Definition (Python) Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Defines the ToastPosition enumeration for specifying where a toast notification should appear on the screen. It includes various positions like top-left, bottom-center, etc. ```python class ToastPosition(Enum): TOP_LEFT = "top-left" TOP_RIGHT = "top-right" TOP_CENTER = "top-center" BOTTOM_LEFT = "bottom-left" BOTTOM_RIGHT = "bottom-right" BOTTOM_CENTER = "bottom-center" ``` -------------------------------- ### ToastVariant Enum Definition (Python) Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Defines the ToastVariant enumeration to control the layout of a toast notification. Options include 'single-line' for a compact view and 'multi-line' for an expanded view. ```python class ToastVariant(Enum): SINGLE_LINE = "single-line" # Compact single line toast MULTI_LINE = "multi-line" # Expanded multi-line toast ``` -------------------------------- ### ToastActionType Enum Definition (Python) Source: https://github.com/bbalduzz/fluentflet/blob/main/README.md Defines the ToastActionType enumeration to specify the type of action button within a toast. Options include no action, a hyperlink, or a default button. ```python class ToastActionType(Enum): NONE = "none" # No action button HYPERLINK = "hyperlink" # Link style action DEFAULT = "default" # Button style action ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.