Rather than creating menus individually, it would be wiser to create a system that will allow us to make all the menus we need. We can do this if we rely on the handy feature of Python that allows us to pass functions and methods between objects.
We'll create a menu system that takes functions or methods as arguments and executes them when menu options are selected. We'll also need to take in the arguments for those functions and methods.
The DirectGUI
system in Panda3D is a series of tools for constructing a graphical user interface. Among the objects in DirectGUI
we can find DirectFrames
to act as the backgrounds of menus, DirectLabels
that will put text on the menus, DirectButtons
that will serve for the menu buttons, and more.
All of the DirectGUI
objects inherit from DirectGUIBase
, so they share many of their features. The typical method for creating a DirectGUI
object is to fill the constructor with keyword/value pairs, like the following:
myDirectGuiObject...