PGEntry

from panda3d.core import PGEntry
class PGEntry

Bases: PGItem

This is a particular kind of PGItem that handles simple one-line or short multi-line text entries, of the sort where the user can type any string.

A PGEntry does all of its internal manipulation on a wide string, so it can store the full Unicode character set. The interface can support either the wide string getters and setters, or the normal 8-bit string getters and setters, which use whatever encoding method is specified by the associated TextNode.

Inheritance diagram

Inheritance diagram of PGEntry

enum State
enumerator S_focus = 0
enumerator S_no_focus = 1
enumerator S_inactive = 2
__init__(name: str)
clearCursorDef()None

Removes all the children from the cursor_def node, in preparation for adding a new definition.

getAcceptEvent(button: ButtonHandle)str

Returns the event name that will be thrown when the entry is accepted normally.

getAcceptFailedEvent(button: ButtonHandle)str

Returns the event name that will be thrown when the entry cannot accept an input

static getAcceptFailedPrefix()str

Returns the prefix that is used to define the accept failed event for all PGEntries. This event is the concatenation of this string followed by get_id().

static getAcceptPrefix()str

Returns the prefix that is used to define the accept event for all PGEntries. The accept event is the concatenation of this string followed by get_id().

getBlinkRate()float

Returns the number of times per second the cursor will blink, or 0 if the cursor is not to blink.

getCandidateActive()str

See setCandidateActive().

getCandidateInactive()str

See setCandidateInactive().

getCharacter(n: int)int

Returns the character at the indicated position in the entry. If the object at this position is a graphic object instead of a character, returns 0.

static getClassType()TypeHandle
getCursorDef()NodePath

Returns the Node that will be rendered to represent the cursor. You can attach suitable cursor geometry to this node.

getCursorKeysActive()bool

Returns whether the arrow keys are currently set to control movement of the cursor; see setCursorKeysActive().

getCursorPosition()int

Returns the current position of the cursor.

getCursorX()float
getCursorY()float
getCursormoveEvent()str

Returns the event name that will be thrown whenever the cursor moves

static getCursormovePrefix()str

Returns the prefix that is used to define the cursor event for all PGEntries. The cursor event is the concatenation of this string followed by get_id().

getEraseEvent()str

Returns the event name that will be thrown whenever the user erases characters in the text.

static getErasePrefix()str

Returns the prefix that is used to define the erase event for all PGEntries. The erase event is the concatenation of this string followed by get_id().

getGraphic(n: int)TextGraphic

Returns the graphic object at the indicated position in the pre-wordwrapped string. If the object at this position is a character instead of a graphic object, returns NULL.

getMaxChars()int

Returns the current maximum number of characters that may be typed into the entry, or 0 if there is no limit. See setMaxChars().

getMaxWidth()float

Returns the current maximum width of the characters that may be typed into the entry, or 0 if there is no limit. See setMaxWidth().

getNumCharacters()int

Returns the number of characters of text in the entry. This is the actual number of visible characters, not counting implicit newlines due to wordwrapping, or formatted characters for text properties changes. If there is an embedded TextGraphic object, it counts as one character.

This is also the length of the string returned by getPlainText().

getNumLines()int

Returns the number of lines of text the PGEntry will use, if _max_width is not 0. See setNumLines().

getObscureMode()bool

Specifies whether obscure mode is enabled. See setObscureMode().

getOverflowEvent()str

Returns the event name that will be thrown when too much text is attempted to be entered into the PGEntry, exceeding either the limit set via setMaxChars() or via setMaxWidth().

getOverflowMode()bool

Specifies whether overflow mode is enabled. See setOverflowMode().

static getOverflowPrefix()str

Returns the prefix that is used to define the overflow event for all PGEntries. The overflow event is the concatenation of this string followed by get_id().

getPlainText()str

Returns the text currently displayed within the entry, without any embedded properties characters.

This uses the Unicode encoding currently specified for the “focus” TextNode; therefore, the TextNode must exist before calling getText().

getPlainWtext()str

Returns the text currently displayed within the entry, without any embedded properties characters.

getProperties(n: int)TextProperties

Returns the TextProperties in effect for the object at the indicated position in the pre-wordwrapped string.

getText()str

Returns the text currently displayed within the entry. This uses the Unicode encoding currently specified for the “focus” TextNode; therefore, the TextNode must exist before calling getText().

getTextDef(state: int)TextNode

Returns the TextNode that will be used to render the text within the entry when the entry is in the indicated state. See setTextDef().

getTypeEvent()str

Returns the event name that will be thrown whenever the user extends the text by typing.

static getTypePrefix()str

Returns the prefix that is used to define the type event for all PGEntries. The type event is the concatenation of this string followed by get_id().

getWtext()str

Returns the text currently displayed within the entry.

isWtext()bool

Returns true if any of the characters in the string returned by getWtext() are out of the range of an ASCII character (and, therefore, getWtext() should be called in preference to getText()).

setAcceptEnabled(enabled: bool)None

Sets whether the input may be accepted–use to disable submission by the user

setBlinkRate(blink_rate: float)None

Sets the number of times per second the cursor will blink while the entry has keyboard focus.

If this is 0, the cursor does not blink, but is held steady.

setCandidateActive(candidate_active: str)None

Specifies the name of the TextProperties structure added to the TextPropertiesManager that will be used to render candidate strings from the IME, used for typing characters in east Asian languages. Each candidate string represents one possible way to interpret the sequence of keys the user has just entered; it should not be considered typed yet, but it is important for the user to be able to see what he is considering entering.

This particular method sets the properties for the subset of the current candidate string that the user can actively scroll through.

setCandidateInactive(candidate_inactive: str)None

Specifies the name of the TextProperties structure added to the TextPropertiesManager that will be used to render candidate strings from the IME, used for typing characters in east Asian languages. Each candidate string represents one possible way to interpret the sequence of keys the user has just entered; it should not be considered typed yet, but it is important for the user to be able to see what he is considering entering.

This particular method sets the properties for the subset of the current candidate string that the user is not actively scrolling through.

setCursorKeysActive(flag: bool)None

Sets whether the arrow keys (and home/end) control movement of the cursor. If true, they are active; if false, they are ignored.

setCursorPosition(position: int)None

Sets the current position of the cursor. This is the position within the text at which the next letter typed by the user will be inserted; normally it is the same as the length of the text.

setMaxChars(max_chars: int)None

Sets the maximum number of characters that may be typed into the entry. This is a limit on the number of characters, as opposed to the width of the entry; see also setMaxWidth().

If this is 0, there is no limit.

setMaxWidth(max_width: float)None

Sets the maximum width of all characters that may be typed into the entry. This is a limit on the width of the formatted text, not a fixed limit on the number of characters; also setMaxChars().

If this is 0, there is no limit.

If _num_lines is more than 1, rather than being a fixed width on the whole entry, this becomes instead the wordwrap width (and the width limit on the entry is essentially _max_width * _num_lines).

setNumLines(num_lines: int)None

Sets the number of lines of text the PGEntry will use. This only has meaning if _max_width is not 0; _max_width indicates the wordwrap width of each line.

setObscureMode(flag: bool)None

Specifies whether obscure mode should be enabled. In obscure mode, a string of asterisks is displayed instead of the literal text, e.g. for entering passwords.

In obscure mode, the width of the text is computed based on the width of the string of asterisks, not on the width of the actual text. This has implications on the maximum length of text that may be entered if max_width is in effect.

setOverflowMode(flag: bool)None

Specifies whether overflow mode should be enabled. In overflow mode, text can overflow the boundaries of the Entry element horizontally.

Overflow mode only works when the number of lines is 1.

setText(text: str)bool

Changes the text currently displayed within the entry. This uses the Unicode encoding currently specified for the “focus” TextNode; therefore, the TextNode must exist before calling setText().

The return value is true if all the text is accepted, or false if some was truncated (see setMaxWidth(), etc.).

setTextDef(state: int, node: TextNode)None

Changes the TextNode that will be used to render the text within the entry when the entry is in the indicated state. The default if nothing is specified is the same TextNode returned by PGItem.getTextNode().

setWtext(wtext: str)bool

Changes the text currently displayed within the entry.

The return value is true if all the text is accepted, or false if some was truncated (see setMaxWidth(), etc.).

setup(width: float, num_lines: int)None

Sets up the entry for normal use. The width is the maximum width of characters that will be typed, and num_lines is the integer number of lines of text of the entry. Both of these together determine the size of the entry, based on the TextNode in effect.

setupMinimal(width: float, num_lines: int)None

Sets up the entry without creating any frame or other decoration.