World > Console#

API Reference#

Console#

class miniworlds.worlds.gui.console.Console(*args, **kwargs)[source]#

A scrolling text console that can be docked to a world.

Use console.newline(text) to append lines of text. The console is a special Toolbar that is typically docked below or beside the main world using world.camera.add_bottom(console) or world.camera.add_right(console).

Examples

console = Console()
world.camera.add_bottom(console)

@world.register
def act(self):
    console.newline("Frame: " + str(world.frame))
__init__()[source]#

Creates a console toolbar with compact text rows.

The console starts with a small default height and is intended for short log messages such as score changes, instructions, or debug output.

dialog#
newline(text)[source]#

Appends a new line of text to the console.

Each call adds one label row. Older lines scroll up when the console is full.

Return type:

Label

Parameters:

text – The text string to display on the new line.

Returns:

The Label actor that was created for this line.

Examples

console.newline("Player position: " + str(player.position))

PagerHorizontal#

class miniworlds.worlds.gui.pager.PagerHorizontal(*args, **kwargs)[source]#
act()[source]#
dialog#
on_setup()[source]#

Hook for initial world setup.

Override this in subclasses or register a function with @world.register.

Examples

@world.register
def on_setup(self):
    self.background = (0, 0, 0)
    Actor((20, 20))