API reference

sgui.init()

Initializes the GUI system. Must be called before any other GUI functions.

class sgui.Window(x, y, w, h, title, collapsed=False, resizable=True, movable=True, titlecolor=<cdata 'struct Color' owning 4 bytes>, scrollable=True)
__init__(x, y, w, h, title, collapsed=False, resizable=True, movable=True, titlecolor=<cdata 'struct Color' owning 4 bytes>, scrollable=True)

A draggable, resizable window container for GUI widgets.

Parameters:
  • x (int) – Initial x position of window

  • y (int) – Initial y position of window

  • w (int) – Width of window content area

  • h (int) – Height of window content area

  • title (str) – Window title text

  • collapsed (bool, optional) – Start collapsed state. Defaults to False.

  • resizable (bool, optional) – Allow window resizing. Defaults to True.

  • movable (bool, optional) – Allow window dragging. Defaults to True.

  • titlecolor (_rl.Color, optional) – Color of title bar. Defaults to cyan.

  • scrollable (bool, optional) – Enable content scrolling. Defaults to True.

gethover()
class sgui.Widget(x, y, w, h, *args)
__init__(x, y, w, h, *args)

Base class for all widgets. Useful for creating custom widgets.

getpressed()
getheld()
class sgui.button(w, label)
__init__(w, label)

Standard button widget with text label.

Parameters:
  • w (int) – Width of the button in pixels

  • label (str) – Text to display on the button

class sgui.button_img(w, h, fp, source=None)
__init__(w, h, fp, source=None)

Image button widget that displays an image instead of text.

Parameters:
  • w (int) – Width of the button in pixels

  • h (int) – Height of the button in pixels

  • fp (str) – File path to the image

  • source (list, optional) – Source rectangle [x,y,w,h] for image. Defaults to None.

class sgui.label(text)
__init__(text)

Text label widget for displaying static text.

Parameters:

text (str) – Text content to display

class sgui.textinput(w: int, label: str, id: str, default='')
__init__(w: int, label: str, id: str, default='') TextInput

Text input field widget for editable text.

Parameters:
  • w (int) – Width of the input field

  • label (str) – Placeholder text when empty

  • id (str) – Unique identifier for this input

  • default (str, optional) – Default text value. Defaults to empty string.

Returns:

TextInput object containing the input state

Return type:

TextInput

class sgui.slider_vec2(w: int, h: int, label: str, id: str, sens: float = 0.005, default=[0, 0])
__init__(w: int, h: int, label: str, id: str, sens: float = 0.005, default=[0, 0])

2D vector slider widget for X/Y coordinate input.

Parameters:
  • w (int) – Width of the slider

  • h (int) – Height of the slider

  • label (str) – Label text

  • id (str) – Unique identifier

  • sens (float, optional) – Mouse sensitivity. Defaults to 0.005.

  • default (list, optional) – Default [x,y] values. Defaults to [0,0].

limit(mini=None, maxi=None)
class sgui.slider(w, label, id, sens=0.005, pressed=False, default=0)
__init__(w, label, id, sens=0.005, pressed=False, default=0)

Single value slider widget for numeric input.

Parameters:
  • w (int) – Width of the slider

  • label (str) – Label text

  • id (str) – Unique identifier

  • sens (float, optional) – Mouse sensitivity. Defaults to 0.005.

  • pressed (bool, optional) – Initial pressed state. Defaults to False.

  • default (int, optional) – Default value. Defaults to 0.

limit(mini=None, maxi=None)
class sgui.solidcolor(w, h, color, border=False)
__init__(w, h, color, border=False)

Solid color rectangle widget.

Parameters:
  • w (int) – Width of rectangle

  • h (int) – Height of rectangle

  • color (list) – RGB color values [r,g,b]

  • border (bool, optional) – Draw border around rectangle. Defaults to False.

class sgui.colorpicker(id, default=[0, 0, 0])
__init__(id, default=[0, 0, 0])

RGB color picker widget with sliders.

Parameters:
  • id (str) – Unique identifier

  • default (list, optional) – Default RGB color values. Defaults to [0,0,0].

class sgui.image(w: int, h: int, fp: str, source: list = None)
__init__(w: int, h: int, fp: str, source: list = None)

Image display widget.

Parameters:
  • w (int) – Width to display image

  • h (int) – Height to display image

  • fp (str) – File path to image

  • source (list, optional) – Source rectangle [x,y,w,h]. Defaults to None for full image.

class sgui.frame(w, h)
__init__(w, h)

Standard frame widget.

Parameters:
  • w (int) – width of the Widget

  • h (int) – height of the Widget

sgui.notify(title, text, duration)

Creates a notification.

sgui.NotifTick()

Ticks the notification system. Must be called every frame.

class sgui.collapsing_header(w, label, id, collapsed=True, indentation=5)
__init__(w, label, id, collapsed=True, indentation=5)

Collapsible section header widget.

Parameters:
  • w (int) – Width of header

  • label (str) – Header text

  • id (str) – Unique identifier

  • collapsed (bool, optional) – Initial collapsed state. Defaults to True.

  • indentation (int, optional) – Child widget indent pixels. Defaults to 5.

show()

Displays the header.

sgui.reset_collapsing_header(id: str)

Resets the collapsing header to its original state.

Parameters:

id (str) – collapsing header identifier

class sgui.checkbox_button(label, id, value=False)
__init__(label, id, value=False)

Checkbox toggle button widget.

Parameters:
  • label (str) – Label text

  • id (str) – Unique identifier

  • value (bool, optional) – Initial checked state. Defaults to False.

class sgui.GUIState

GUI state, example usage might be to edit widget values or see if a widget uses a keyboard key.

Keyboard = []
Mouse = []
MouseWheel = False
Widgets = {}
SpecialWindows = {}
SelectedWidget = 0
Curwidget = 0
Notifications = []
NotifHeight = []
get_is_current()
get_window()
sgui.set_indent(value)

Sets the indent level for widgets. Default is 0.

sgui.sameline()

Puts widgets next to eachother

sgui.cancel_sameline()

Cancels the last sameline call.

sgui._log(text)

Prints a log message with a timestamp and what function called it.