direct.showbase.ShowBase

from direct.showbase.ShowBase import ShowBase, WindowControls, exitfunc

This module contains ShowBase, an application framework responsible for opening a graphical display, setting up input devices and creating the scene graph.

The simplest way to open a ShowBase instance is to execute this code:

from direct.showbase.ShowBase import ShowBase

base = ShowBase()
base.run()

A common approach is to create your own subclass inheriting from ShowBase.

Built-in global variables

Some key variables used in all Acron scripts are actually attributes of the ShowBase instance. When creating an instance of this class, it will write many of these variables to the built-in scope of the Python interpreter, so that they are accessible to any Python module, without the need for extra imports. For example, the ShowBase instance itself is accessible anywhere through the base variable.

While these are handy for prototyping, we do not recommend using them in bigger projects, as it can make the code confusing to read to other Python developers, to whom it may not be obvious where these variables are originating.

Refer to the builtins page for a listing of the variables written to the built-in scope.

Inheritance diagram

digraph inheritance28f7964b76 { bgcolor=transparent; rankdir=BT; size="8.0, 12.0"; "DirectObject" [URL="direct.showbase.DirectObject.html#direct.showbase.DirectObject.DirectObject",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="This is the class that all Direct/SAL classes should inherit from"]; "ShowBase" [URL="direct.showbase.ShowBase.html#direct.showbase.ShowBase.ShowBase",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top"]; "DirectObject" -> "ShowBase" [arrowsize=0.75,style=""]; "WindowControls" [URL="direct.showbase.ShowBase.html#direct.showbase.ShowBase.WindowControls",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top"]; }
class ShowBase(fStartDirect: bool = True, windowType: str | None = None)[source]

Bases: DirectObject

a2dTopLeft: NodePath
aspect2d: NodePath
bboard

The global bulletin board, as imported from BulletinBoardGlobal.

bufferViewer

Utility for viewing offscreen buffers, see BufferViewer.

cTrav: CollisionTraverser | Literal[0]

A placeholder for a CollisionTraverser. If someone stores a CollisionTraverser pointer here, ShowBase will traverse it automatically in the collisionLoop task, so you won’t need to call traverse() yourself every frame.

cam: NodePath | None

This is a NodePath pointing to the Camera object set up for the 3D scene. Usually a child of camera.

cam2d: NodePath | None

Same as cam, but for the 2D scene graph.

cam2dp: NodePath | None

Same as cam2d, but for the 2D overlay scene graph.

camLens: Lens | None

Convenience accessor for base.camNode.get_lens(), containing a Lens object.

camList: list[NodePath]

A list of all cameras created with makeCamera(), including cam.

camNode: Camera | None

Convenience accessor for base.cam.node(), containing a Camera object.

camera: NodePath | None

This is the NodePath that should be used to manipulate the camera. It points at the node to which the default camera (cam, camNode) is attached.

camera2d: NodePath | None

Same as camera, but for the 2D scene graph. Parent of cam2d.

camera2dp: NodePath | None

Same as camera2d, but for the 2D overlay scene graph. Parent of cam2dp.

clock

This is the global ClockObject.

cluster: Any | None
config: ClassVar = <module 'direct.showbase.DConfig' from '/home/frain/work/astracron/acron-docs/.venv/lib/python3.14/site-packages/direct/showbase/DConfig.py'>

The deprecated DConfig interface for accessing config variables.

devices

This is the global InputDeviceManager, which keeps track of connected input devices.

eventMgr

The global event manager, as imported from EventManagerGlobal.

exitFunc: Callable[[], object] | None

Fill this in with a function to invoke when the user “exits” the program by closing the main window.

finalExitCallbacks: list[Callable[[], object]]

Add final-exit callbacks to this list. These will be called when sys.exit() is called, after Acron has unloaded, and just before Python is about to shut down.

graphicsEngine

The global GraphicsEngine, as returned by GraphicsEngine.getGlobalPtr()

guiItems: ClassVar[dict]
jobMgr

The global job manager, as imported from JobManagerGlobal.

loader: Loader.Loader

Loader.Loader object.

mainDir

The directory containing the main Python file of this application.

messenger

The global messenger, as imported from MessengerGlobal.

mouseWatcherNode: MouseWatcher | None

The MouseWatcher object, created by setupMouse().

notify: ClassVar[Notifier] = <direct.directnotify.Notifier.Notifier object>
particleMgr

If enableParticles() has been called, this is the particle manager as imported from direct.particles.ParticleManagerGlobal.

physicsMgr

If enableParticles() has been called, this is the physics manager as imported from direct.showbase.PhysicsManagerGlobal.

pipe: GraphicsPipe | None

Contains the GraphicsPipe object created by makeDefaultPipe().

pipeList: list[GraphicsPipe]

The full list of GraphicsPipe objects, including any auxiliary pipes. Filled by makeAllPipes().

pixel2d: NodePath
render2d: NodePath
taskMgr

The global task manager, as imported from TaskManagerGlobal.

transitions

Transitions.Transitions object.

win: GraphicsOutput | None

This is the main, or only window; see winList for a list of all windows.

winList: list[GraphicsEngine]

A list of all windows opened via openWindow().

windowType

This is set to the value of the window-type config variable, but may optionally be overridden in the Showbase constructor. Should either be ‘onscreen’ (the default), ‘offscreen’ or ‘none’.

wxApp: Any | None

This is used to store the wx.Application object used when want-wx is set or startWx() is called.

class WindowControls(win, cam=None, camNode=None, cam2d=None, mouseWatcher=None, mouseKeyboard=None, closeCmd=<function WindowControls.<lambda>>, grid=None)[source]

Bases: object