Widget
class Widget
Bases: Widget
, Service
The base widget, all other Fabric widgets should inherit from this class
- Parameters:
- name (str | None , optional) — the name identifer for this widget (useful for styling), defaults to None
- visible (bool , optional) — whether should this widget be visible or not once initialized, defaults to True
- all_visible (bool , optional) — whether should this widget and all of its children 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” ] | Gtk.Align | None , optional) — horizontal alignment of this widget (compared to its parent), defaults to None
- v_align (Literal [ “fill” , “start” , “end” , “center” , “baseline” ] | Gtk.Align | None , optional) — vertical alignment of this widget (compared to its parent), defaults to None
- h_expand (bool , optional) — whether should this widget fill in all the available horizontal space or not, defaults to False
- v_expand (bool , optional) — whether should this widget 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 guranteed to get applied), defaults to None
property style_classes list[str]
The list of this widget’s current style classes
- Returns: a list holding the currently active style classes on this widget
- Return type: list[str]
property v_align Align
This widget’s vertical alignment (compared to its parent)
- Returns: vertical alignment mode
- Return type: Gtk.Align
property h_align Align
This widget’s horizontal alignment (compared to its parent)
- Returns: horizontal alignment mode
- Return type: Gtk.Align
property v_expand bool
Whether should this widget expand vertically to fill the available space or not
- Return type: bool
property h_expand bool
Whether should this widget expand horizontally to fill the available space or not
- Return type: bool
def set_alignment (orientation: Literal['v', 'vertical', 'h', 'horizontal'] | Orientation, alignment: Literal['fill', 'start', 'end', 'center', 'baseline'] | Align)
Set the alignment mode for a given orientation
- Parameters:
- orientation (Literal [ “v” , “vertical” , “h” , “horizontal” ] | Gtk.Orientation) — the orientation for which the alignment should be applied
- alignment (Literal [ “fill” , “start” , “end” , “center” , “baseline” ] | Gtk.Align) — the alignment mode for the given orientation
def set_style (style: str, compile: bool = True, append: bool = False, add_brackets: bool = True) None
Set widget’s stylesheet from a string
- Parameters:
- style (str) — the css style
- compile (bool , optional) — whether to compile the style or not, defaults to True
- append (bool , optional) — whether to append this style to other loaded styles (if any) or not, if this is set to False it will clear all other styles before applying, defaults to False
- add_brackets — whether to add brackets to the style if they were missing (e.g.
padding: 10; something-useful: unset;
was passed;* { padding: 10; something-useful: unset; }
was applied), defaults to True
def set_cursor
def set_cursor (cursor: None, pixbuf: gi.overrides.GdkPixbuf.Pixbuf | None = None, x_offset: int = 0, y_offset=0)
def set_cursor
def is_hovered (event: EventAny | None = None) bool
Lookup if this widget is begin currently hovered by the user or not (not accurate)
- Parameters: event (Gdk.EventAny | None , optional) — a GdkEvent to extract geometry data from (if any), defaults to None
- Returns: a bool that indicates whether this widget is begin hovered or not
- Return type: bool
def add_style_class (class_name: str | Iterable[str])
Add a style class (or more) to this widget
- Parameters: class_name (str | Iterable *[*str ]) — a class name or an iterable of class names to be added
def remove_style_class (class_name: str | Iterable[str])
Remove a style class (or more) to this widget
- Parameters: class_name (str | Iterable *[*str ]) — a class name or an iterable of class names to be removed
def add_events
Add more events to this widget so it’s able to handle more event types
- Parameters: events (EVENT_TYPE | Gdk.EventMask | Iterable *[*EVENT_TYPE | Gdk.EventMask ]) — a named event, GdkEventMask or a list of both to be registered as available event types on this widget