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.
At a glance
15 membersReference
PYTHON APIConstructor
methodui.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
propertybackground_color: Color | NoneThe background color of the element (if no texture is provided).
border_color
propertyborder_color: Color | NoneThe color of the border.
border_radius
propertyborder_radius: floatThe radius of the border corners.
border_width
propertyborder_width: intThe width of the border.
font
propertyfont: FontThe font to use for text rendering.
gap
propertygap: floatThe gap between child elements.
height
propertyheight: float | NoneThe height of the element.
margin
propertymargin: floatThe margin around the element.
offset
propertyoffset: Vec2The offset of the element within its parent.
padding
propertypadding: floatThe padding around the element.
slice
propertyslice: RectThe region of the texture to use.
text_color
propertytext_color: Color | NoneThe color of the text.
texture
propertytexture: TextureThe texture to use for the element.
width
propertywidth: float | NoneThe width of the element.