World > Camera > Docking#

Verwende world.camera.add_right(...), world.camera.add_bottom(...) und world.camera.switch_world(...) als öffentliche API zum Andocken und Umschalten von Hilfswelten.

Die folgende Klasse ist der interne Helfer, der dieses Verhalten hinter der öffentlichen Kamera-API implementiert.

API Reference#

class miniworlds.worlds.manager.layout_manager.LayoutManager(world, app)[Quellcode]#

LayoutManager handles the positioning and management of World objects within an application window.

Es wird intern unter world._layout gespeichert, waehrend die öffentliche API ueber world.camera bereitgestellt wird und das Layout-Verhalten an App und WorldsManager delegiert.

Public Data Attributes:

window_docking_position

Returns the docking position of this world in the window layout.

Public Methods:

__init__(world, app)

Initialize a LayoutManager for a given world and application.

add_right(world[, size])

Adds a new world to the right side of the current world.

add_bottom(world[, size])

Adds a new world below the current world.

remove_world(world)

Removes a world from the current layout.

switch_world(new_world[, reset])

Switches focus to another world.

Private Methods:

_add_to_window(app, dock[, size])

Internal method to integrate this world into the window system.


__init__(world, app)[Quellcode]#

Initialize a LayoutManager for a given world and application.

Parameter:
  • world – The World instance that owns this layout manager.

  • app – The application instance managing all worlds.

Example

>>> world.camera.add_right(Toolbar(), size=150)
add_bottom(world, size=100)[Quellcode]#

Adds a new world below the current world.

Rückgabetyp:

World

Parameter:
  • world – The World instance to dock.

  • size – Height of the added world in pixels (default: 100).

Rückgabe:

The newly added World instance.

Example

>>> world.camera.add_bottom(Console(), size=200)
add_right(world, size=100)[Quellcode]#

Adds a new world to the right side of the current world.

Rückgabetyp:

World

Parameter:
  • world – The World instance to dock.

  • size – Width of the added world in pixels (default: 100).

Rückgabe:

The newly added World instance.

Example

>>> world.camera.add_right(Toolbar(), size=150)
remove_world(world)[Quellcode]#

Removes a world from the current layout.

Rückgabetyp:

None

Parameter:

world – The World instance to remove.

Example

>>> world.camera.remove_world(toolbar)
switch_world(new_world, reset=False)[Quellcode]#

Switches focus to another world.

Rückgabetyp:

None

Parameter:
  • new_world – The World instance to activate.

  • reset – Whether to reset the world state (default: False).

Example

>>> world.camera.switch_world(main_scene, reset=True)
property window_docking_position: str | None#

Returns the docking position of this world in the window layout.

Rückgabe:

A string such as „right“ or „bottom“, or None if undocked.

Example

>>> world.camera.window_docking_position
'right'