Context

class pyegui.Context

Context object that controls global aspects of your app

Usage:

def update_func(ctx):
    ctx.set_light_theme
    heading("Using light theme even if system's is dark")

run_native("My app", update_func)
Context.is_light_theme

True when theme is dark

Context.is_dark_theme

True when theme is dark

Context.set_dark_theme()

Sets dark theme. Default is system’s

Context.set_light_theme()

Sets light theme. Default is system’s

Context.set_system_theme()

Sets system’s theme if it has been changed.

Context.set_font(source)

Tell egui which fonts to use.

The default egui fonts only support latin and cyrillic alphabets, but you can call this to install additional fonts that support e.g. Japanese characters.

The new fonts will become active at the start of the next pass. This will overwrite the existing fonts.

Example:

def update_func(ctx):
  ctx.set_font("NotoSansJP-VariableFont_wght.ttf")
  heading("天気の子")
Context.open_url(url)

Open an URL in a browser.

Context.copy_text(text)

Copy the given text to the system clipboard.