direct.gui.DirectOptionMenu

from direct.gui.DirectOptionMenu import DirectOptionMenu

Implements a pop-up menu containing multiple clickable options.

See the DirectOptionMenu page in the programming manual for a more in-depth explanation and an example of how to use this class.

Inheritance diagram

Inheritance diagram of direct.gui.DirectOptionMenu

class DirectOptionMenu(parent=None, **kw)[source]

Bases: direct.gui.DirectButton.DirectButton

DirectOptionMenu(parent) - Create a DirectButton which pops up a menu which can be used to select from a list of items. Execute button command (passing the selected item through) if defined To cancel the popup menu click anywhere on the screen outside of the popup menu. No command is executed in this case.

__init__(self, parent=None, **kw)[source]
commandFunc(self, event)[source]

Override popup menu button’s command func Command is executed in response to selecting menu items

get(self)[source]

Get currently selected item

hidePopupMenu(self, event=None)[source]

Put away popup and cancel frame

index(self, index)[source]
selectHighlightedIndex(self, event=None)[source]

Check to see if item is highlighted (by cursor being within that item). If so, selected it. If not, do nothing

set(self, index, fCommand=1)[source]
setItems(self)[source]

self[‘items’] = itemList Create new popup menu to reflect specified set of items

showPopupMenu(self, event=None)[source]

Make popup visible and try to position it just to right of mouse click with currently selected item aligned with button. Adjust popup position if default position puts it outside of visible screen region