PGItem

from panda3d.core import PGItem
class PGItem

Bases: PandaNode

This is the base class for all the various kinds of gui widget objects.

It is a Node which corresponds to a rectangular region on the screen, and it may have any number of “state” subgraphs, one of which is rendered at any given time according to its current state.

The PGItem node must be parented to the scene graph somewhere beneath a PGTop node in order for this behavior to work.

Inheritance diagram

Inheritance diagram of PGItem

__init__(name: str)
clearFrame()None

Removes the bounding rectangle from the item. It will no longer be possible to position the mouse within the item; see setFrame().

clearSound(event: str)None

Removes the sound associated with the indicated event.

clearStateDef(state: int)None

Resets the NodePath assigned to the indicated state to its initial default, with only a frame representation if appropriate.

getActive()bool

Returns whether the PGItem is currently active for mouse events. See setActive().

getBackgroundFocus()bool

Returns whether background_focus is currently enabled. See setBackgroundFocus().

static getClassType()TypeHandle
getEnterEvent()str

Returns the event name that will be thrown when the item is active and the mouse enters its frame, but not any nested frames.

static getEnterPrefix()str

Returns the prefix that is used to define the enter event for all PGItems. The enter event is the concatenation of this string followed by getId().

getExitEvent()str

Returns the event name that will be thrown when the item is active and the mouse exits its frame, or enters a nested frame.

static getExitPrefix()str

Returns the prefix that is used to define the exit event for all PGItems. The exit event is the concatenation of this string followed by getId().

getFocus()bool

Returns whether the PGItem currently has focus for keyboard events. See setFocus().

getFocusInEvent()str

Returns the event name that will be thrown when the item gets the keyboard focus.

static getFocusInPrefix()str

Returns the prefix that is used to define the focus_in event for all PGItems. The focus_in event is the concatenation of this string followed by getId().

Unlike most item events, this event is thrown with no parameters.

static getFocusItem()PGItem

Returns the one PGItem in the world that currently has keyboard focus, if any, or NULL if no item has keyboard focus. Use PGItem.setFocus() to activate or deactivate keyboard focus on a particular item.

getFocusOutEvent()str

Returns the event name that will be thrown when the item loses the keyboard focus.

static getFocusOutPrefix()str

Returns the prefix that is used to define the focus_out event for all PGItems. The focus_out event is the concatenation of this string followed by getId().

Unlike most item events, this event is thrown with no parameters.

getFrame()LVecBase4

Returns the bounding rectangle of the item. See setFrame(). It is an error to call this if hasFrame() returns false.

getFrameInvXform()LMatrix4

Returns the inverse of the frame transform matrix

getFrameStyle(state: int)PGFrameStyle

Returns the kind of frame that will be drawn behind the item when it is in the indicated state.

getId()str

Returns the unique ID assigned to this PGItem. This will be assigned to the region created with the MouseWatcher, and will thus be used to generate event names.

getKeystrokeEvent()str

Returns the event name that will be thrown when the item is active and any key is pressed by the user.

static getKeystrokePrefix()str

Returns the prefix that is used to define the keystroke event for all PGItems. The keystroke event is the concatenation of this string followed by a hyphen and getId().

getNumStateDefs()int

Returns one more than the highest-numbered state def that was ever assigned to the PGItem. The complete set of state defs assigned may then be retrieved by indexing from 0 to (get_num_state_defs() - 1).

This is only an upper limit on the actual number of state defs, since there may be holes in the list.

getPressEvent(button: ButtonHandle)str

Returns the event name that will be thrown when the item is active and the indicated mouse or keyboard button is depressed while the mouse is within the frame.

static getPressPrefix()str

Returns the prefix that is used to define the press event for all PGItems. The press event is the concatenation of this string followed by a button name, followed by a hyphen and getId().

getReleaseEvent(button: ButtonHandle)str

Returns the event name that will be thrown when the item is active and the indicated mouse or keyboard button, formerly clicked down is within the frame, is released.

static getReleasePrefix()str

Returns the prefix that is used to define the release event for all PGItems. The release event is the concatenation of this string followed by a button name, followed by a hyphen and getId().

getRepeatEvent(button: ButtonHandle)str

Returns the event name that will be thrown when the item is active and the indicated mouse or keyboard button is continuously held down while the mouse is within the frame.

static getRepeatPrefix()str

Returns the prefix that is used to define the repeat event for all PGItems. The repeat event is the concatenation of this string followed by a button name, followed by a hyphen and getId().

getSound(event: str)AudioSound

Returns the sound associated with the indicated event, or NULL if there is no associated sound.

getState()int

Returns the “state” of this particular PGItem. See setState().

getStateDef(state: int)NodePath

Returns the Node that is the root of the subgraph that will be drawn when the PGItem is in the indicated state. The first time this is called for a particular state index, it may create the Node.

getStateDefs()list
getSuppressFlags()int

This is just an interface to get the suppress flags on the underlying MouseWatcherRegion. See MouseWatcherRegion.getSuppressFlags().

static getTextNode()TextNode

Returns the TextNode object that will be used by all PGItems to generate default labels given a string. This can be loaded with the default font, etc.

getWithinEvent()str

Returns the event name that will be thrown when the item is active and the mouse moves within the boundaries of the frame. This is different from the enter_event in that the mouse is considered within the frame even if it is also within a nested frame.

static getWithinPrefix()str

Returns the prefix that is used to define the within event for all PGItems. The within event is the concatenation of this string followed by getId().

getWithoutEvent()str

Returns the event name that will be thrown when the item is active and the mouse moves completely outside the boundaries of the frame. This is different from the exit_event in that the mouse is considered within the frame even if it is also within a nested frame.

static getWithoutPrefix()str

Returns the prefix that is used to define the without event for all PGItems. The without event is the concatenation of this string followed by getId().

hasFrame()bool

Returns true if the item has a bounding rectangle; see setFrame().

hasSound(event: str)bool

Returns true if there is a sound associated with the indicated event, or false otherwise.

hasStateDef(state: int)bool

Returns true if getStateDef() has ever been called for the indicated state (thus defining a render subgraph for this state index), false otherwise.

instanceToStateDef(state: int, path: NodePath)NodePath

Parents an instance of the bottom node of the indicated NodePath to the indicated state index.

setActive(active: bool)None

Sets whether the PGItem is active for mouse watching. This is not necessarily related to the active/inactive appearance of the item, which is controlled by setState(), but it does affect whether it responds to mouse events.

setBackgroundFocus(focus: bool)None

Sets the background_focus flag for this item. When background_focus is enabled, the item will receive keypress events even if it is not in focus; in fact, even if it is not onscreen. Unlike normal focus, many items may have background_focus simultaneously.

setFocus(focus: bool)None

Sets whether the PGItem currently has keyboard focus. This simply means that the item may respond to keyboard events as well as to mouse events; precisely what this means is up to the individual item.

Only one PGItem in the world is allowed to have focus at any given time. Setting the focus on any other item automatically disables the focus from the previous item.

setFrame(frame: LVecBase4)None

Sets the bounding rectangle of the item, in local coordinates. This is the region on screen within which the mouse will be considered to be within the item. Normally, it should correspond to the bounding rectangle of the visible geometry of the item.

setFrame(left: float, right: float, bottom: float, top: float)None

Sets the bounding rectangle of the item, in local coordinates. This is the region on screen within which the mouse will be considered to be within the item. Normally, it should correspond to the bounding rectangle of the visible geometry of the item.

setFrameStyle(state: int, style: PGFrameStyle)None

Changes the kind of frame that will be drawn behind the item when it is in the indicated state.

setId(id: str)None

Set the unique ID assigned to this PGItem. It is the user’s responsibility to ensure that this ID is unique.

Normally, this should not need to be called, as the PGItem will assign itself an ID when it is created, but this function allows the user to decide to redefine the ID to be something possibly more meaningful.

setName(name: str)None
setSound(event: str, sound: AudioSound)None

Sets the sound that will be played whenever the indicated event occurs.

setState(state: int)None

Sets the “state” of this particular PGItem.

The PGItem node will render as if it were the subgraph assigned to the corresponding index via set_state_def().

setSuppressFlags(suppress_flags: int)None

This is just an interface to set the suppress flags on the underlying MouseWatcherRegion. See MouseWatcherRegion.setSuppressFlags().

static setTextNode(node: TextNode)None

Changes the TextNode object that will be used by all PGItems to generate default labels given a string. This can be loaded with the default font, etc.