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- 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 calltraverse()yourself every frame.
- cam: NodePath | None¶
This is a
NodePathpointing to theCameraobject set up for the 3D scene. Usually a child ofcamera.
- camera: NodePath | None¶
This is the
NodePaththat should be used to manipulate the camera. It points at the node to which the default camera (cam,camNode) is attached.
- clock¶
This is the global
ClockObject.
- 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
DConfiginterface 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()
- jobMgr¶
The global job manager, as imported from
JobManagerGlobal.
- loader: Loader.Loader¶
Loader.Loaderobject.
- mainDir¶
The directory containing the main Python file of this application.
- messenger¶
The global messenger, as imported from
MessengerGlobal.
- mouseWatcherNode: MouseWatcher | None¶
The
MouseWatcherobject, created bysetupMouse().
- particleMgr¶
If
enableParticles()has been called, this is the particle manager as imported fromdirect.particles.ParticleManagerGlobal.
- physicsMgr¶
If
enableParticles()has been called, this is the physics manager as imported fromdirect.showbase.PhysicsManagerGlobal.
- pipe: GraphicsPipe | None¶
Contains the
GraphicsPipeobject created bymakeDefaultPipe().
- pipeList: list[GraphicsPipe]¶
The full list of
GraphicsPipeobjects, including any auxiliary pipes. Filled bymakeAllPipes().
- taskMgr¶
The global task manager, as imported from
TaskManagerGlobal.
- transitions¶
Transitions.Transitionsobject.
- win: GraphicsOutput | None¶
This is the main, or only window; see
winListfor 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’.