### Initialize and Run Application Source: https://wiki.ffpy.org/guide/fabricators Shows the basic setup for running a Fabric application. It initializes an `Application` instance and starts its execution. ```python app = Application() app.run() ``` -------------------------------- ### Python Comment Formatting Example Source: https://wiki.ffpy.org/contributing/code-style-guide Demonstrates the correct way to format comments in Python code according to PEP 8 guidelines. Avoids incorrect comment styles. ```python # Like this. ``` -------------------------------- ### Conventional Commits Specification Example Source: https://wiki.ffpy.org/contributing/code-style-guide Provides an example of commit messages following the Conventional Commits specification, including type, scope, description, body, and footers. This ensures consistency in commit history. ```git [optional scope]: [optional body] [optional footer(s)] ``` ```git feat: Add `balloons` argument to `Universe.celebrating_koalas` ``` ```git fix: Check for fraudulent koalas before allocating balloons ``` -------------------------------- ### GTK CSS Naming Conventions: Good Examples Source: https://wiki.ffpy.org/guide/styling Provides examples of correctly formatted CSS naming conventions in GTK, emphasizing the use of kebab-case for selectors and class names. This ensures consistency and readability. ```css #my-widget { /* ... */ } #my-widget .class-name { /* ... */ } ``` -------------------------------- ### Install Fabric Dependencies Source: https://wiki.ffpy.org/contributing/development-environment Installs the project dependencies listed in 'requirements.txt' and then installs the current Fabric source code in editable mode. The editable mode allows changes to the source code to be reflected immediately without reinstallation. ```bash pip install -r requirements.txt pip install -e . ``` -------------------------------- ### Run the Status Bar Application Source: https://wiki.ffpy.org/guide/first-widget Initializes and runs the StatusBar application. It creates an instance of StatusBar, wraps it in an Application, and starts the event loop. ```python if __name__ == "__main__": bar = StatusBar() app = Application("bar", bar) app.run() ``` -------------------------------- ### Navigate to Fabric Directory Source: https://wiki.ffpy.org/contributing/development-environment Changes the current working directory to the newly cloned 'fabric' repository. This is necessary to perform subsequent setup commands within the project's root. ```bash cd fabric ``` -------------------------------- ### Create Layouts with Boxes and Labels using Fabric Source: https://wiki.ffpy.org/guide/first-widget This example showcases how to use `Box` widgets in Fabric to arrange other widgets, including labels. It demonstrates vertical and horizontal orientations, spacing, and nesting `Box` widgets. ```python import fabric from fabric import Application from fabric.widgets.box import Box from fabric.widgets.label import Label from fabric.widgets.window import Window if __name__ == "__main__": box_1 = Box( orientation="v", children=Label(label="this is the first box") ) box_2 = Box( spacing=28, orientation="h", children=[ Label(label="this is the first element in the second box"), Label(label="btw, this box elements will get added horizontally") ] ) box_1.add(box_2) window = Window(child=box_1) app = Application("default", window) app.run() ``` -------------------------------- ### Send Command to I3/Sway IPC Source: https://wiki.ffpy.org/guide/window-managers This example shows how to send commands to the I3/Sway IPC socket using the I3 service. It includes specifying the message type, such as `GET_WORKSPACES`, for retrieving data. ```python from fabric.i3.service import I3, I3MessageType workspaces_reply = I3.send_command("", message_type=I3MessageType.GET_WORKSPACES) ``` -------------------------------- ### Create Status Bar for X11 with Fabric Source: https://wiki.ffpy.org/guide/first-widget This code example shows how to create a simple status bar using Fabric for X11 environments. It utilizes an X11-specific window and incorporates a date-time widget. Key dependencies are the fabric library and its associated widgets. ```python import fabric from fabric import Application from fabric.widgets.datetime import DateTime from fabric.widgets.centerbox import CenterBox from fabric.widgets.x11 import X11Window as Window class StatusBar(Window): def __init__(self, **kwargs): super().__init__( layer="top", geometry="top", type_hint="dock", **kwargs ) self.date_time = DateTime() self.children = CenterBox(center_children=self.date_time) if __name__ == "__main__": bar = StatusBar() app = Application("bar-example", bar) app.run() ``` -------------------------------- ### Create a Documents Size Fabricator with Shell Command Source: https://wiki.ffpy.org/guide/fabricators An example of a Fabricator that monitors the size of the Documents directory using the `du -sh` shell command. It polls every second and prints the size. ```python # NOTE: this is just an example, the use of something like os would be better documents_fabricator = Fabricator( interval=1000, # 1 second poll_from="du -sh /home/homan/Documents/", # NOTE: edit this on_changed=lambda f, v: print(f"Size of Documents: {v.split()[0]}"), ) # example output: # Size of Documents: 1G # Size of Documents: 1.1G # ... ``` -------------------------------- ### Define a Basic Service in Python Source: https://wiki.ffpy.org/guide/services Demonstrates the minimal structure for defining a service by inheriting from Fabric's `Service` class. This serves as a foundational example for creating custom services. ```python from fabric.core.service import Service class MyService(Service):... ``` -------------------------------- ### WaylandWindow Initialization and Properties in Python Source: https://wiki.ffpy.org/api/widgets/wayland This snippet demonstrates the initialization of a WaylandWindow with various parameters and accessing its properties. It covers setting the layer, anchor, margin, exclusivity, keyboard mode, pass-through behavior, monitor, title, type, child widget, name, visibility, styling, tooltips, alignment, expansion, and size. The example also shows how to retrieve the current monitor assigned to the window. ```python from gi.repository import Gtk, Gdk from layer_shell import GtkLayerShell from fabric.window import WaylandWindow, WaylandWindowExclusivity, KeyboardMode, WindowType # Example initialization of a WaylandWindow window = WaylandWindow( layer=GtkLayerShell.Layer.BOTTOM, # Place the window at the bottom layer anchor="top right", # Anchor the window to the top and right edges margin="10px 5px 10px 5px", # Set margins: top, right, bottom, left exclusivity=WaylandWindowExclusivity.NORMAL, # Reserve space around the window keyboard_mode=GtkLayerShell.KeyboardMode.ON_DEMAND, # Handle keyboard input on demand pass_through=True, # Allow mouse events to pass through to windows below monitor=0, # Display on the primary monitor (monitor ID 0) title="My Dock Window", # Set a custom title for the window type=WindowType.TOPLEVEL, # Set the window type to top-level child=Gtk.Label(label="Hello Wayland!"), # Add a Gtk.Label as a child widget name="my-dock", # Assign a name for styling purposes visible=True, # Ensure the window is visible style_classes=["dock-style"], # Apply custom style classes tooltip_text="This is a Wayland dock.", # Set tooltip text h_align=Gtk.Align.CENTER, # Center align horizontally v_align=Gtk.Align.START, # Align to the top vertically h_expand=True, # Allow horizontal expansion v_expand=False, # Do not allow vertical expansion size=(300, 50) # Set a fixed size (width, height) ) # Accessing window properties current_monitor = window.monitor window_title = window.title print(f"Window title: {window_title}") print(f"Current monitor ID: {current_monitor}") Gtk.main() ``` -------------------------------- ### GTK CSS Naming Conventions: Bad Examples Source: https://wiki.ffpy.org/guide/styling Illustrates incorrect CSS naming conventions in GTK, highlighting issues with mixed cases, underscores, and double hyphens. Adhering to kebab-case is crucial for maintainable styles. ```css #My_Widget { /* ... */ } #My-Widget { /* ... */ } #myWidget { /* ... */ } #my-widget .Class--name { /* ... */ } ``` -------------------------------- ### Define a Basic Window with a Label using Fabric Source: https://wiki.ffpy.org/guide/first-widget This snippet demonstrates how to create a simple window containing a 'Hello, World!' label using the Fabric framework. It imports necessary classes, instantiates `Window` and `Label` widgets, and runs the Fabric application. ```python import fabric from fabric import Application from fabric.widgets.label import Label from fabric.widgets.window import Window window = Window( child = Label("Hello, World"), all_visible=True ) app = Application("default", window) app.run() ``` -------------------------------- ### Python Inline Conditional Statement Example Source: https://wiki.ffpy.org/contributing/code-style-guide Shows how to use inline if-statements in Python when a condition only changes the value of a single object. This promotes conciseness. ```python x = "the x object" if unexpected_feature is not True else "the x man" ``` -------------------------------- ### Initialize Image Widget with Image File (Python) Source: https://wiki.ffpy.org/api/widgets/image Demonstrates initializing the Image widget using a local image file path. This is suitable for displaying custom images. Requires the `image_file` parameter to be a valid string path. ```python from typing import Iterable, Literal from gi.repository import Align class Image: def __init__(self, image_file: str | None = None, icon_name: None = None, icon_size: int = 24, pixbuf: None = None, name: str | None = None, visible: bool = True, all_visible: bool = False, style: str | None = None, style_classes: Iterable[str] | str | None = None, tooltip_text: str | None = None, tooltip_markup: str | None = None, h_align: Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None = None, v_align: Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None = None, h_expand: bool = False, v_expand: bool = False, size: Iterable[int] | int | None = None, **kwargs): pass # Example Usage: image_widget = Image(image_file="path/to/your/image.png") ``` -------------------------------- ### Window Class Constructor Source: https://wiki.ffpy.org/api/widgets/window This section describes the parameters available when initializing a new Window object. ```APIDOC ## Window Class Constructor ### Description Initializes a new Window object with various configuration options. ### Method Constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **title** (str) - Optional - The title of this window (used for window manager scoping), defaults to “fabric”. * **type** (Literal['top-level', 'popup'] | WindowType) - Optional - The type of this window (useful with some window managers), defaults to Gtk.WindowType.TOPLEVEL. * **child** (Widget | None) - Optional - A child widget to add into this window, defaults to None. * **name** (str | None) - Optional - The name identifier for this widget (useful for styling), defaults to None. * **visible** (bool) - Optional - Whether this widget should be visible or not once initialized, defaults to True. * **all_visible** (bool) - Optional - Whether this widget and all of its children should be visible or not once initialized, defaults to False. * **style** (str | None) - Optional - Inline stylesheet to be applied on this widget, defaults to None. * **style_classes** (Iterable[str] | str | None) - Optional - A list of style classes to be added into this widget once initialized, defaults to None. * **tooltip_text** (str | None) - Optional - The text that should be rendered inside the tooltip, defaults to None. * **tooltip_markup** (str | None) - Optional - Same as tooltip_text but it accepts simple markup expressions, defaults to None. * **h_align** (Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None) - Optional - Horizontal alignment of this widget (compared to its parent), defaults to None. * **v_align** (Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None) - Optional - Vertical alignment of this widget (compared to its parent), defaults to None. * **h_expand** (bool) - Optional - Whether this widget should fill in all the available horizontal space or not, defaults to False. * **v_expand** (bool) - Optional - Whether this widget should fill in all the available vertical space or not, defaults to False. * **size** (Iterable[int] | int | None) - Optional - A fixed size for this widget (not guaranteed to get applied), defaults to None. ### Request Example ```json { "example": "Window(title='My App', type='popup', visible=False)" } ``` ### Response #### Success Response (200) * **Window** (Window) - The newly created Window object. #### Response Example ```json { "example": "<__main__.Window object at 0x... >" } ``` ``` -------------------------------- ### Get Hyprland Connection Function Source: https://wiki.ffpy.org/api/widgets/hyprland This Python function establishes a connection to Hyprland. It is a core utility for interacting with the Hyprland compositor and likely requires specific Hyprland libraries to be installed. ```python def get_hyprland_connection(): # Function implementation to connect to Hyprland pass ``` -------------------------------- ### Python Regular Conditional Statement Example Source: https://wiki.ffpy.org/contributing/code-style-guide Illustrates the use of regular if-else statements in Python when a block of code needs to be executed. This is preferred over multiple inline conditionals for clarity. ```python if unexpected_feature is True: x = "the unknown guy" y = "idk" z = 4002 ... ``` -------------------------------- ### Container Widget Initialization (Python) Source: https://wiki.ffpy.org/api/widgets/container Demonstrates the initialization of the Container widget in Python. It accepts various parameters to configure its appearance, behavior, and child widgets. Key parameters include children, name, visibility, styling, alignment, and expansion. ```python class Container(children: Widget | Iterable[Widget] | None = None, name: str | None = None, visible: bool = True, all_visible: bool = False, style: str | None = None, style_classes: Iterable[str] | str | None = None, tooltip_text: str | None = None, tooltip_markup: str | None = None, h_align: Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None = None, v_align: Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None = None, h_expand: bool = False, v_expand: bool = False, size: Iterable[int] | int | None = None, **kwargs) ``` -------------------------------- ### Initialize Image Widget with Icon Name (Python) Source: https://wiki.ffpy.org/api/widgets/image Shows how to initialize the Image widget using a named icon from a system's icon theme. This is useful for displaying standard UI icons. Requires the `icon_name` parameter to be a string representing the icon's name. ```python from typing import Iterable, Literal from gi.repository import Align class Image: def __init__(self, image_file: None = None, icon_name: str | None = None, icon_size: int = 24, pixbuf: None = None, name: str | None = None, visible: bool = True, all_visible: bool = False, style: str | None = None, style_classes: Iterable[str] | str | None = None, tooltip_text: str | None = None, tooltip_markup: str | None = None, h_align: Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None = None, v_align: Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None = None, h_expand: bool = False, v_expand: bool = False, size: Iterable[int] | int | None = None, **kwargs): pass # Example Usage: icon_widget = Image(icon_name="document-save", size=32) ``` -------------------------------- ### CenterBox Methods Source: https://wiki.ffpy.org/api/widgets/centerbox Methods for adding and removing individual widgets from the start, center, and end sections of the CenterBox. ```APIDOC ## CenterBox Add/Remove Methods ### Description Provides methods to programmatically add or remove specific widgets from the start, center, and end areas of the `CenterBox`. ### Methods #### `add_start(widget: Widget)` - **Description**: Adds a widget to the start section. - **Parameters**: - **widget** (Widget) - The widget to add. #### `add_center(widget: Widget)` - **Description**: Adds a widget to the center section. - **Parameters**: - **widget** (Widget) - The widget to add. #### `add_end(widget: Widget)` - **Description**: Adds a widget to the end section. - **Parameters**: - **widget** (Widget) - The widget to add. #### `remove_start(widget: Widget)` - **Description**: Removes a widget from the start section. - **Parameters**: - **widget** (Widget) - The widget to remove. #### `remove_center(widget: Widget)` - **Description**: Removes a widget from the center section. - **Parameters**: - **widget** (Widget) - The widget to remove. #### `remove_end(widget: Widget)` - **Description**: Removes a widget from the end section. - **Parameters**: - **widget** (Widget) - The widget to remove. ### Example ```python from gi.repository import Gtk box = CenterBox() start_label = Gtk.Label(label='Left') center_button = Gtk.Button(label='Middle') end_icon = Gtk.Image.new_from_icon_name('dialog-information', Gtk.IconSize.BUTTON) box.add_start(start_label) box.add_center(center_button) box.add_end(end_icon) # Remove the button from the center box.remove_center(center_button) ``` ``` -------------------------------- ### Window Application Property Source: https://wiki.ffpy.org/api/widgets/window Retrieves the application instance associated with the window. ```APIDOC ## Window Application Property ### Description Gets the application instance associated with this window. ### Method GET ### Endpoint `/websites/wiki_ffpy/Window/application` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "GET /websites/wiki_ffpy/Window/application" } ``` ### Response #### Success Response (200) * **application** (Application) - The application instance associated with the window. #### Response Example ```json { "example": "<__main__.Application object at 0x... >" } ``` ``` -------------------------------- ### CenterBox Properties Source: https://wiki.ffpy.org/api/widgets/centerbox Access and modify the child widgets within the start, center, and end sections of the CenterBox. ```APIDOC ## CenterBox Child Management ### Description These properties allow direct access to the lists of widgets contained within the start, center, and end sections of the `CenterBox`. ### Properties - **start_children** (list[Widget]) - Read/Write - A list of widgets currently in the start section. - **center_children** (list[Widget]) - Read/Write - A list of widgets currently in the center section. - **end_children** (list[Widget]) - Read/Write - A list of widgets currently in the end section. ### Example ```python from gi.repository import Gtk box = CenterBox() label = Gtk.Label(label='Dynamic') # Add a widget to the center box.center_children.append(label) # Accessing children print(f"Start children: {box.start_children}") print(f"Center children: {box.center_children}") print(f"End children: {box.end_children}") ``` ``` -------------------------------- ### CenterBox Widget Initialization Source: https://wiki.ffpy.org/api/widgets/centerbox Initializes a CenterBox widget with optional start, center, and end children, spacing, and orientation. ```APIDOC ## CenterBox Widget ### Description Creates a widget that arranges its children into three distinct areas: start, center, and end. It supports vertical or horizontal orientation and configurable spacing. ### Method `CenterBox(...)` ### Parameters #### Initialization Parameters - **start_children** (Widget | Iterable[Widget] | None) - Optional - A widget or an iterable of widgets to be placed in the start section. - **center_children** (Widget | Iterable[Widget] | None) - Optional - A widget or an iterable of widgets to be placed in the center section. - **end_children** (Widget | Iterable[Widget] | None) - Optional - A widget or an iterable of widgets to be placed in the end section. - **spacing** (int) - Optional - Default: 0 - The spacing between child widgets. - **orientation** (Literal['v', 'vertical', 'h', 'horizontal'] | Orientation) - Optional - Default: Gtk.Orientation.HORIZONTAL - The orientation of the box, either horizontal or vertical. - **name** (str | None) - Optional - The name of the widget. - **visible** (bool) - Optional - Default: True - Whether the widget is visible. - **all_visible** (bool) - Optional - Default: False - Whether all children must be visible for the widget to be visible. - **style** (str | None) - Optional - CSS style string. - **style_classes** (Iterable[str] | str | None) - Optional - CSS style classes. - **tooltip_text** (str | None) - Optional - Tooltip text. - **tooltip_markup** (str | None) - Optional - Tooltip markup. - **h_align** (Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None) - Optional - Horizontal alignment. - **v_align** (Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None) - Optional - Vertical alignment. - **h_expand** (bool) - Optional - Default: False - Whether the widget expands horizontally. - **v_expand** (bool) - Optional - Default: False - Whether the widget expands vertically. - **size** (Iterable[int] | int | None) - Optional - The preferred size of the widget. - **kwargs** - Additional keyword arguments. ### Request Example ```python from gi.repository import Gtk # Example of creating a CenterBox with widgets start_widget = Gtk.Label(label='Start') center_widget = Gtk.Label(label='Center') end_widget = Gtk.Label(label='End') box = CenterBox( start_children=[start_widget], center_children=[center_widget], end_children=[end_widget], spacing=10, orientation=Gtk.Orientation.HORIZONTAL ) ``` ### Response N/A (This is a widget constructor, not an API endpoint response) ``` -------------------------------- ### CenterBox Widget Properties Source: https://wiki.ffpy.org/api/widgets/centerbox Accessors for the lists of widgets contained within the start, center, and end sections of the CenterBox. These properties allow introspection and manipulation of the widget composition within each section. ```python start_children: list[Widget] center_children: list[Widget] end_children: list[Widget] ``` -------------------------------- ### CHANGELOG.md Commit Logging Format Source: https://wiki.ffpy.org/contributing/code-style-guide Defines the format for logging changes in the CHANGELOG.md file, linking changes to pull requests and commit messages. This helps track project evolution. ```markdown -- Format -- . <#Pull-Request-Number> -- Examples -- 1. <#Pull-Request-Number> feat: something awesome! 2. <#Pull-Request-Number> feat: new method to do magic! 3. <#Pull-Request-Number> fix: fabricated, this fixes/closes ! 4. refactor: i dunno how to fabricate XD ``` -------------------------------- ### Image Widget Constructors Source: https://wiki.ffpy.org/api/widgets/image The Image widget can be initialized in three ways: by providing an image file, an icon name, or a pixbuf. ```APIDOC ## Image Widget Constructors ### Description The Image widget can be initialized with an image file, an icon name, or a pixbuf. Various optional parameters control its appearance and behavior. ### Method Constructor ### Parameters **Constructor 1: Image from file** #### Path Parameters * None #### Query Parameters * None #### Request Body * **image_file** (str | None) - Optional - Path to the image file. * **icon_name** (None) - Reserved for other constructors. * **icon_size** (int) - Optional - Size of the icon if used (default: 24). * **pixbuf** (None) - Reserved for other constructors. * **name** (str | None) - Optional - Name of the widget. * **visible** (bool) - Optional - Whether the widget is visible (default: True). * **all_visible** (bool) - Optional - Whether all parts of the widget are visible (default: False). * **style** (str | None) - Optional - CSS style string. * **style_classes** (Iterable[str] | str | None) - Optional - CSS style classes. * **tooltip_text** (str | None) - Optional - Tooltip text. * **tooltip_markup** (str | None) - Optional - Tooltip markup. * **h_align** (Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None) - Optional - Horizontal alignment. * **v_align** (Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None) - Optional - Vertical alignment. * **h_expand** (bool) - Optional - Whether to expand horizontally (default: False). * **v_expand** (bool) - Optional - Whether to expand vertically (default: False). * **size** (Iterable[int] | int | None) - Optional - Size of the widget. * **kwargs** - Additional keyword arguments. **Constructor 2: Image from icon name** #### Path Parameters * None #### Query Parameters * None #### Request Body * **image_file** (None) - Reserved for other constructors. * **icon_name** (str | None) - Optional - Name of the icon. * **icon_size** (int) - Optional - Size of the icon (default: 24). * **pixbuf** (None) - Reserved for other constructors. * **name** (str | None) - Optional - Name of the widget. * **visible** (bool) - Optional - Whether the widget is visible (default: True). * **all_visible** (bool) - Optional - Whether all parts of the widget are visible (default: False). * **style** (str | None) - Optional - CSS style string. * **style_classes** (Iterable[str] | str | None) - Optional - CSS style classes. * **tooltip_text** (str | None) - Optional - Tooltip text. * **tooltip_markup** (str | None) - Optional - Tooltip markup. * **h_align** (Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None) - Optional - Horizontal alignment. * **v_align** (Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None) - Optional - Vertical alignment. * **h_expand** (bool) - Optional - Whether to expand horizontally (default: False). * **v_expand** (bool) - Optional - Whether to expand vertically (default: False). * **size** (Iterable[int] | int | None) - Optional - Size of the widget. * **kwargs** - Additional keyword arguments. **Constructor 3: Image from pixbuf** #### Path Parameters * None #### Query Parameters * None #### Request Body * **image_file** (None) - Reserved for other constructors. * **icon_name** (None) - Reserved for other constructors. * **icon_size** (int) - Optional - Size of the icon if used (default: 24). * **pixbuf** (Pixbuf | None) - Optional - A pixbuf object. * **name** (str | None) - Optional - Name of the widget. * **visible** (bool) - Optional - Whether the widget is visible (default: True). * **all_visible** (bool) - Optional - Whether all parts of the widget are visible (default: False). * **style** (str | None) - Optional - CSS style string. * **style_classes** (Iterable[str] | str | None) - Optional - CSS style classes. * **tooltip_text** (str | None) - Optional - Tooltip text. * **tooltip_markup** (str | None) - Optional - Tooltip markup. * **h_align** (Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None) - Optional - Horizontal alignment. * **v_align** (Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None) - Optional - Vertical alignment. * **h_expand** (bool) - Optional - Whether to expand horizontally (default: False). * **v_expand** (bool) - Optional - Whether to expand vertically (default: False). * **size** (Iterable[int] | int | None) - Optional - Size of the widget. * **kwargs** - Additional keyword arguments. ### Request Example ```json { "image_file": "/path/to/your/image.png" } ``` ```json { "icon_name": "zoom-in", "icon_size": 32 } ``` ```json { "pixbuf": "" } ``` ### Response #### Success Response (200) * **Widget** (object) - The created Image widget instance. #### Response Example ```json { "widget_type": "Image", "properties": { "image_file": "/path/to/your/image.png", "icon_name": null, "pixbuf": null, "name": null, "visible": true, "all_visible": false, "style": null, "style_classes": [], "tooltip_text": null, "tooltip_markup": null, "h_align": "fill", "v_align": "fill", "h_expand": false, "v_expand": false, "size": null } } ``` ``` -------------------------------- ### Points Property for Star - FFPy Python Source: https://wiki.ffpy.org/api/widgets/shapes/star A property to get or set the number of points for the star. This attribute directly influences the geometry of the star shape. ```python property points: int ``` -------------------------------- ### Show Window Using show_all or all_visible Parameter Source: https://wiki.ffpy.org/getting-started/faq This snippet demonstrates how to ensure a window is displayed correctly in Fabric. It checks for blocking code before Fabric initialization and suggests using the `show_all` function or the `all_visible=True` parameter to make the window visible. This is crucial for debugging window display issues. ```python def show_all(self): """Show all widgets in the window. This is useful for debugging when a window does not appear. """ self.window.show_all() # Example usage: # window.all_visible = True # window.show_all() ``` -------------------------------- ### GTK Default Stylesheet Reset Source: https://wiki.ffpy.org/guide/styling Demonstrates how to reset default GTK stylesheets to start styling from scratch. It involves creating a `style.css` file with `* { all: unset; }` and loading it via `Application.set_stylesheet_from_file()`. ```css * { all: unset; } ``` ```python app = Application() app.set_stylesheet_from_file("path/to/style.css") ``` -------------------------------- ### Create Python Virtual Environment Source: https://wiki.ffpy.org/contributing/development-environment Creates a new Python virtual environment named 'venv' within the current project directory. This isolates project dependencies from the global Python installation. ```bash python -m venv venv ``` -------------------------------- ### Window Add Keybinding Method Source: https://wiki.ffpy.org/api/widgets/window Adds a callback for a specific keybinding. ```APIDOC ## Window Add Keybinding Method ### Description Adds a callback function to be executed when a specific key combination is pressed. ### Method POST ### Endpoint `/websites/wiki_ffpy/Window/add_keybinding` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **keybind** (str) - Required - The string representing the keybinding (e.g. “Ctrl w”). * **callback** (Callable[[Self, Any], Any]) - Required - The callback function to be called once the given keybinding is received. ### Request Example ```json { "keybind": "Ctrl+s", "callback": "def handle_save(window, event): print('Saved!')" } ``` ### Response #### Success Response (200) * **reference** (int) - The keybinding connection's ID, which can be used for disconnecting later. #### Response Example ```json { "reference": 12345 } ``` ``` -------------------------------- ### Activate Python Virtual Environment Source: https://wiki.ffpy.org/contributing/development-environment Sources the newly created virtual environment, activating it for the current terminal session. This ensures that subsequent Python commands and package installations use the virtual environment. ```bash source venv/bin/activate ``` -------------------------------- ### List Running Fabric Instances Source: https://wiki.ffpy.org/getting-started/client-and-cli Demonstrates how to list all currently running Fabric instances using the `list-all` command. The `-j` flag can be used for JSON serialization of the output. ```bash $ python -m fabric list-all my-bar: /home/homan/.config/fabric/config.py ``` ```bash $ python -m fabric list-all -j # json serialization {'instances-dbus-names': ['org.Fabric.fabric.my-bar']} ``` -------------------------------- ### Hyprland Connection Utility Source: https://wiki.ffpy.org/api/fabric Utility function for establishing a connection to Hyprland. ```APIDOC ## Hyprland Connection Utility ### Description Provides a function to get a connection object for interacting with Hyprland. ### Functions - `get_hyprland_connection()` - Establishes and returns a connection to Hyprland. ``` -------------------------------- ### SystemTrayItem Object Source: https://wiki.ffpy.org/api/fabric Documentation for the SystemTrayItem object, detailing its properties and methods for managing system tray icons. ```APIDOC ## SystemTrayItem Object ### Description Represents an item in the system tray, providing properties to manage its appearance and behavior, and methods to interact with it. ### Properties - `id` (number) - Unique identifier for the system tray item. - `identifier` (string) - A string identifier for the system tray item. - `title` (string) - The title or tooltip displayed for the item. - `status` (string) - The current status of the item. - `category` (string) - The category of the system tray item. - `window_id` (number) - The ID of the associated window, if any. - `icon_theme_path` (string) - Path to the icon theme for the item. - `icon_theme` (string) - The name of the icon theme. - `icon_name` (string) - The name of the icon. - `icon_pixmap` (object) - Pixmap representation of the icon. - `overlay_icon_name` (string) - Name of an overlay icon. - `overlay_icon_pixmap` (object) - Pixmap representation of the overlay icon. - `attention_icon_name` (string) - Name of the attention icon. - `attention_icon_pixmap` (object) - Pixmap representation of the attention icon. - `tooltip` (string) - Tooltip text for the item. - `is_menu` (boolean) - Indicates if the item is a menu. - `menu_object_path` (string) - Object path for the associated menu. - `menu` (object) - The menu object associated with the item. ### Methods - `context_menu()` - Displays the context menu for the item. - `activate()` - Activates the system tray item. - `secondary_activate()` - Performs a secondary activation action on the item. - `invoke_menu_for_event(event)` - Invokes the menu for a given event. - `scroll(direction)` - Handles scrolling events for the item. - `context_menu_for_event(event)` - Returns the context menu for a specific event. - `activate_for_event(event)` - Activates the item for a specific event. - `secondary_activate_for_event(event)` - Performs a secondary activation for a specific event. - `scroll_for_event(event)` - Handles scrolling for a specific event. ``` -------------------------------- ### CenterBox Widget Methods: Remove Children Source: https://wiki.ffpy.org/api/widgets/centerbox Methods to remove a specific widget from the start, center, or end sections of the CenterBox. These functions are essential for dynamically updating the UI by detaching widgets from their designated layout areas. ```python def remove_start(widget: Widget) def remove_center(widget: Widget) def remove_end(widget: Widget) ``` -------------------------------- ### get_desktop_applications Source: https://wiki.ffpy.org/api/utils/utils Retrieves a list of all available desktop applications. ```APIDOC ## get_desktop_applications ### Description Retrieves a list of all available desktop applications. This can be useful for creating application launchers. ### Parameters - **include_hidden** (bool, optional) - Whether to include applications not intended for normal user visibility. Defaults to False. ### Returns A list of DesktopApp objects representing the available applications. ### Return type list[DesktopApp] ``` -------------------------------- ### CenterBox Widget Methods: Add Children Source: https://wiki.ffpy.org/api/widgets/centerbox Methods to add a single widget to the start, center, or end sections of the CenterBox. These methods facilitate dynamic modification of the layout by appending new widgets to their respective zones. ```python def add_start(widget: Widget) def add_center(widget: Widget) def add_end(widget: Widget) ``` -------------------------------- ### Initialize FlowBox Widget (Python) Source: https://wiki.ffpy.org/api/widgets/flowbox Demonstrates the initialization of a FlowBox widget in Python using GTK. This includes setting properties like spacing, orientation, and children. ```python from gi.repository import Gtk # Create a FlowBox with horizontal orientation and spacing flow_box = Gtk.FlowBox( row_spacing=5, column_spacing=5, orientation=Gtk.Orientation.HORIZONTAL ) ``` -------------------------------- ### Ratio Property for Star - FFPy Python Source: https://wiki.ffpy.org/api/widgets/shapes/star A property to get or set the ratio of the star, which likely controls the inner and outer radius relationship. This affects the star's 'sharpness'. ```python property ratio: float ``` -------------------------------- ### Fabricator Initialization using Direct Chaining Source: https://wiki.ffpy.org/guide/services Demonstrates initializing a Fabricator object by chaining builder methods like build(), connect(), set_value(), and unwrap(). The unwrap() method is crucial for returning the actual Fabricator instance. This method is suitable for straightforward configurations. ```python fabricator = Fabricator( poll_from=lambda: "hello there!", interval=1000, ).build() .connect("changed", lambda *_: print("changed")) .connect("notify::value", lambda *_: print("value notified")) .set_value("initial value") .unwrap() # Return the actual Fabricator, not the Builder object ``` -------------------------------- ### Window API Source: https://wiki.ffpy.org/api/fabric Provides access to window properties and methods for managing keybindings. ```APIDOC ## Window API ### Description This section details the properties and methods available for general Window management. ### Properties - `Window.application`: Accesses the application associated with the window. ### Methods - `Window.add_keybinding()`: Adds a keybinding to the window. - `Window.remove_keybinding()`: Removes a keybinding from the window. ``` -------------------------------- ### Fabricator Initialization using Callback Method Source: https://wiki.ffpy.org/guide/services Illustrates initializing a Fabricator object using a callback function passed to the build() method. This callback receives the service instance and the builder, allowing for more flexible and encapsulated configuration logic. It's useful for complex initialization scenarios. ```python fabricator = Fabricator( poll_from=lambda: "hello there!", interval=1000, ).build( lambda self, builder: builder .connect("changed", lambda *_: print("changed")) .connect("notify::value", lambda *_: print("value notified")) .set_value("initial value") ) ``` -------------------------------- ### Evaluate Python Code with Fabric CLI Source: https://wiki.ffpy.org/getting-started/client-and-cli Illustrates how to evaluate a Python expression within a running Fabric instance using the `evaluate` command. This command returns the result of the evaluation. An example of an error return is also shown. ```bash $ python -m fabric evaluate my-bar "bar.this_method_does_not_exist()" # should return an error exception: AttributeError("'StatusBar' object has no attribute 'this_method_does_not_exist'") ``` -------------------------------- ### Create Status Bar for Wayland with Fabric Source: https://wiki.ffpy.org/guide/first-widget This code demonstrates how to create a simple status bar using Fabric for Wayland environments. It initializes a Wayland-specific window and adds a date-time widget to the center. Dependencies include the fabric library and its widgets. ```python import fabric from fabric import Application from fabric.widgets.datetime import DateTime from fabric.widgets.centerbox import CenterBox from fabric.widgets.wayland import WaylandWindow as Window class StatusBar(Window): def __init__(self, **kwargs): super().__init__( layer="top", anchor="left top right", exclusivity="auto", **kwargs ) self.date_time = DateTime() self.children = CenterBox(center_children=self.date_time) if __name__ == "__main__": bar = StatusBar() app = Application("bar-example", bar) app.run() ``` -------------------------------- ### Get List of Desktop Applications Source: https://wiki.ffpy.org/api/utils/utils Fetches a list of all available desktop applications on the system. This function can optionally include hidden applications based on the `include_hidden` parameter. It's useful for building application launchers or system information tools. ```python from typing import List from gi.overrides import GioUnix # Assuming DesktopApp class is defined elsewhere # class DesktopApp: # pass def get_desktop_applications(include_hidden: bool = False) -> List[GioUnix.DesktopAppInfo]: """Get a list of all desktop applications. Args: include_hidden: Whether to include applications unintended to be visible to normal users, defaults to false. Returns: A list of all desktop applications. """ # Implementation would use Gio.DesktopAppInfo.get_all or similar ``` -------------------------------- ### Define and Initialize Box Widget in Python Source: https://wiki.ffpy.org/api/widgets/box Demonstrates the definition and initialization of the Box widget in Python. This widget serves as a container for other GUI elements and allows for flexible layout management through its various properties. ```python from typing import Literal, Iterable from gi.repository import Gtk, Gtk.Orientation, Gtk.Align class Box(Gtk.Box, Gtk.Container): def __init__(self, spacing: int = 0, orientation: Literal['v', 'vertical', 'h', 'horizontal'] | Gtk.Orientation = Gtk.Orientation.HORIZONTAL, children: Widget | Iterable[Widget] | None = None, name: str | None = None, visible: bool = True, all_visible: bool = False, style: str | None = None, style_classes: Iterable[str] | str | None = None, tooltip_text: str | None = None, tooltip_markup: str | None = None, h_align: Literal['fill', 'start', 'end', 'center', 'baseline'] | Gtk.Align | None = None, v_align: Literal['fill', 'start', 'end', 'center', 'baseline'] | Gtk.Align | None = None, h_expand: bool = False, v_expand: bool = False, size: Iterable[int] | int | None = None, **kwargs ): # Widget implementation details would go here ``` -------------------------------- ### Initialize Image Widget with Pixbuf (Python) Source: https://wiki.ffpy.org/api/widgets/image Illustrates initializing the Image widget with a `Pixbuf` object, which represents an image in memory. This is useful when you have image data already loaded or generated. Requires a `Pixbuf` object for the `pixbuf` parameter. ```python from typing import Iterable, Literal from gi.repository import Align from gi.repository import GdkPixbuf # Assuming Pixbuf is from GdkPixbuf class Image: def __init__(self, image_file: None = None, icon_name: None = None, icon_size: int = 24, pixbuf: GdkPixbuf.Pixbuf | None = None, name: str | None = None, visible: bool = True, all_visible: bool = False, style: str | None = None, style_classes: Iterable[str] | str | None = None, tooltip_text: str | None = None, tooltip_markup: str | None = None, h_align: Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None = None, v_align: Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None = None, h_expand: bool = False, v_expand: bool = False, size: Iterable[int] | int | None = None, **kwargs): pass # Example Usage: # Assuming you have a pixbuf object named 'my_pixbuf' # my_pixbuf = GdkPixbuf.Pixbuf.new_from_file("path/to/image.png") # image_from_pixbuf = Image(pixbuf=my_pixbuf) ``` -------------------------------- ### CenterBox Widget Definition Source: https://wiki.ffpy.org/api/widgets/centerbox Defines the CenterBox widget, inheriting from Box. It allows for the arrangement of child widgets into start, center, and end sections, with options for spacing and orientation. This widget is useful for creating layouts with distinct zones for different UI elements. ```python class CenterBox(start_children: Widget | Iterable[Widget] | None = None, center_children: Widget | Iterable[Widget] | None = None, end_children: Widget | Iterable[Widget] | None = None, spacing: int = 0, orientation: Literal['v', 'vertical', 'h', 'horizontal'] | Orientation = Gtk.Orientation.HORIZONTAL, name: str | None = None, visible: bool = True, all_visible: bool = False, style: str | None = None, style_classes: Iterable[str] | str | None = None, tooltip_text: str | None = None, tooltip_markup: str | None = None, h_align: Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None = None, v_align: Literal['fill', 'start', 'end', 'center', 'baseline'] | Align | None = None, h_expand: bool = False, v_expand: bool = False, size: Iterable[int] | int | None = None, **kwargs): pass ``` -------------------------------- ### DesktopApp Object Source: https://wiki.ffpy.org/api/fabric Represents a desktop application, providing information about its properties and launch capabilities. ```APIDOC ## DesktopApp Object ### Description Represents a desktop application, exposing details like its name, executable path, and icon, and providing a method to launch it. ### Properties - `name` (string) - The name of the application. - `generic_name` (string) - The generic name of the application. - `display_name` (string) - The display name of the application. - `description` (string) - A description of the application. - `window_class` (string) - The window class name. - `executable` (string) - The path to the application's executable. - `command_line` (string) - The command line used to launch the application. - `icon` (string) - The icon name for the application. - `icon_name` (string) - The explicit icon name. - `hidden` (boolean) - Indicates if the application is hidden. ### Methods - `launch()` - Launches the desktop application. ```