gale.ui.theme module

This file contains the implementation of the class Theme, the shared set of colors/fonts/spacing every widget falls back to unless given its own.

Author: Alejandro Mujica (aledrums@gmail.com)

class gale.ui.theme.Theme(font=None, text_color=(235, 235, 235, 255), background_color=(30, 30, 34, 255), border_color=(235, 235, 235, 255), border_width=1, accent_color=(90, 200, 255, 255), hover_color=(55, 60, 75, 255), focus_color=(255, 210, 60, 255), disabled_color=(120, 120, 120, 255), padding=4)[source]

Bases: object

A bundle of style values every widget reads from, either its own (passed to its constructor) or a shared default one.

Usage example:

pygame.font.init() dark_theme = Theme(font=pygame.font.Font(None, 20)) panel = Panel(10, 10, 200, 100, theme=dark_theme)

Parameters:
  • font (Font | None)

  • text_color (Color)

  • background_color (Color)

  • border_color (Color)

  • border_width (int)

  • accent_color (Color)

  • hover_color (Color)

  • focus_color (Color)

  • disabled_color (Color)

  • padding (int)

gale.ui.theme.get_default_theme()[source]
Returns:

The current default theme, creating one with every value defaulted the first time this is called.

Return type:

Theme

gale.ui.theme.set_default_theme(theme)[source]

Replace the default theme every widget created without an explicit theme falls back to. Existing widgets read gale.ui.theme.get_default_theme() fresh on every render, so this takes effect immediately, without having to recreate them.

Parameters:

theme (Theme) – The new default theme.

Return type:

None