peng3d.gui.text - Textual Widgets¶
-
class
peng3d.gui.text.Label(name: Optional[str], submenu: SubMenu, window: Any = None, peng: Any = None, *, pos: Union[List[float], Callable[[float, float, float, float], Tuple[float, float]], layout.LayoutCell], size: Union[List[float], Callable[[float, float], Tuple[float, float]], None] = None, bg=None, label='Label', font_size=None, font=None, font_color=None, multiline=False, label_cls=<Mock name='mock.Label' id='140340375806032'>, anchor_x='center', anchor_y='center', label_layer=1)[source]¶ Simple widget that can display any single-line non-formatted string.
This widget does not use any background by default.
The default font color is chosen to work on the default background color and may need to be changed if the background color is changed.
-
label¶ Property for accessing the text of the label.
-
-
class
peng3d.gui.text.TextInput(name: Optional[str], submenu: SubMenu, window: Any = None, peng: Any = None, *args, pos: Union[List[float], Callable[[float, float, float, float], Tuple[float, float]], layout.LayoutCell], size: Union[List[float], Callable[[float, float], Tuple[float, float]], None] = None, bg=None, text='', default='', border=[4, 4], borderstyle=None, font_size=None, font=None, font_color=None, font_color_default=[62, 67, 73, 200], allow_overflow=False, allow_copypaste=True, min_size=None, parent_bgcls=None, allow_returnkey=False, **kwargs)[source]¶ Basic Textual Input widget.
By default, this widget uses
TextInputBackgroundas its Background class.The optional default text will only be displayed if the text is empty.
The
allow_overflowflag determines if the text entered can be longer than the size of theTextInput.The
allow_copypasteflag controls whether or not the user can copy and paste the contents of the text box. By default, copying and pasting is allowed. This flag can also be set to"force"to force a crash with an appropriate error message if thepyperclipmodule is not available. Currently, only copying, pasting and cutting the whole text box is supported, as there is no mechanism for text selection yet.The key combinations used by this widget can be configured in the config via the
controls.keybinds.common.*config values.parent_bgclsmay be used to override the background used. Note that the cursor will still be rendered. Additional parameters required by the custom background should be passed as keyword arguments. Note that arguments already used by TextInput are not passed down. This may cause issues with ButtonBackground and some other classes.allow_returnkeydetermines whether pressing the return key inserts a\rcharacter or not. Note that thesend_formaction of the submenu may still be sent, even if this is set to true.-
default¶ Property for accessing the default text.
-
on_redraw()[source]¶ Draws the background and the widget itself.
Subclasses should use
super()to call this method, or rendering may glitch out.
-
redraw_label()[source]¶ Re-draws the label by calculating its position.
Currently, the label will always be centered on the position of the label.
-
text¶ Property for accessing the text.
-
-
class
peng3d.gui.text.TextInputBackground(*args, **kwargs)[source]¶ Background for the
TextInputWidget.This background uses the button drawing routines and adds a cursor.
-
init_bg()[source]¶ Called just before the background will be drawn the first time.
Commonly used to initialize vertex lists.
It is recommended to add all vertex lists to the
submenu.batch2dBatch to speed up rendering and preventing glitches with grouping.
-
pressed¶ Read-only helper property to be used by borderstyles for determining if the widget should be rendered as pressed or not.
Note that this property may not represent the actual pressed state, it will always be False if
change_on_pressis disabled.
-
-
class
peng3d.gui.text.CustomTextInputBackground(widget, cls=<class 'peng3d.gui.button.ButtonBackground'>, *args, **kwargs)[source]¶ Background for the
TextInputWidget.This background adds a cursor on top of another background.