sgc Package

All widgets are imported into sgc namespace. This means you can access widgets in sgc namespace, such as sgc.Button.

Module Packages:
widgets: All the widgets available for use in this toolkit.
Modules:
locals: Constants to be imported into the local namespace for convenience.
surface: Extended pygame.surface classes.
class Font

Class containing fonts available for use.

Index class to get fonts, such as Font["widget"] for the widget font.

The default fonts are:
widget: The default font for widgets.
title: A larger title font.
mono: A monospaced font.
Attributes:
col: (r,g,b) tuple, containing the default font colour.
col = (255, 255, 255)
classmethod set_fonts(fonts={})

Set fonts to a specific font. If a font exists, it will be replaced, otherwise it will be newly created.

Args:
fonts: Dictionary containing fonts to use.
Key should be name of font. Value should be string
naming either custom FreeType or a system font.
update(time)

Updates all active widgets or modal widgets each frame.

event(event)

Send event to focused widget and handle widget focus.

locals Module

Imports useful objects into the local namespace.

Constants:
GUI: Event type for any event emitted by this toolkit.
class EventSlot(widget, event, funcs=())

Bases: object

Event slots object. Allows dynamic allocation of events. Args:

widget: The widget you want to bind this event slot to.
event: str The attribute you want to bind to (e.g. ‘on_click’).
funcs: A sequence of functions you want to include by default.
add(func)

Add additional functions to be called.

Args:
func: A function or sequence of functions to be added.
remove(func)

Remove functions from the existing set of functions.

Args:
func: A function or sequence of functions to be removed.

surface Module

Screen class to store rect information with the screen and setup the toolkit.

class Screen(size, flags=0, depth=0)

Bases: object

Class for the screen.

This must be used instead of pygame.display.set_mode().

Attributes:
image: The pygame.display screen.
rect: pygame.Rect containing screen size.
Args:
size, flags, depth: Arguments for pygame.display.set_mode()
rect
image

Table Of Contents

Previous topic

Theming

Next topic

widgets Package