CLASS v1.8.0

ui.Style

pykraken.ui.Style

Container for UI appearance, layout, and sizing settings.

More about ui.Style

Styles can provide background textures or colors, text settings, spacing, borders, and optional fixed width and height constraints.

Reference

PYTHON API
ui.Style(background_color: Color | None = None, texture: Texture | None = None, slice: Rect = Rect(x=0.000000, y=0.000000, w=0.000000, h=0.000000), offset: Vec2 = Vec2(0.000000, 0.000000), font: Font | None = None, text_color: Color | None = None, padding: float = 0.0, margin: float = 0.0, gap: float = 0.0, border_width: int = 0, border_radius: float = 0.0, border_color: Color | None = None, width: float | None = None, height: float | None = None)

Create a new style definition for UI elements.

Args

  • background_color (Color, optional) — The background color of the element if no texture is used.
  • texture (Texture, optional) — The texture to draw behind the element.
  • slice (Rect, optional) — The 9-slice margins used when drawing the texture.
  • offset (Vec2, optional) — The element offset relative to its parent. Defaults to (0, 0).
  • font (Font, optional) — The font to use for text rendering.
  • text_color (Color, optional) — The text color.
  • padding (float, optional) — Inner padding around the content. Defaults to 0.0.
  • margin (float, optional) — Outer margin around the element. Defaults to 0.0.
  • gap (float, optional) — Space between child elements. Defaults to 0.0.
  • border_width (int, optional) — Border thickness. Defaults to 0.
  • border_radius (float, optional) — Radius used for rounded corners. Defaults to 0.0.
  • border_color (Color, optional) — Border color.
  • width (float, optional) — Fixed element width.
  • height (float, optional) — Fixed element height.
background_color: Color | None

The background color of the element (if no texture is provided).

border_color

property
border_color: Color | None

The color of the border.

border_radius: float

The radius of the border corners.

border_width

property
border_width: int

The width of the border.

font

property
font: Font

The font to use for text rendering.

gap

property
gap: float

The gap between child elements.

height

property
height: float | None

The height of the element.

margin

property
margin: float

The margin around the element.

offset

property
offset: Vec2

The offset of the element within its parent.

padding

property
padding: float

The padding around the element.

slice

property
slice: Rect

The region of the texture to use.

text_color

property
text_color: Color | None

The color of the text.

texture

property
texture: Texture

The texture to use for the element.

width

property
width: float | None

The width of the element.

Find your next step

Start typing to search the manual.