__init__(self,
x,
y,
width=None,
height=None,
text='',
anchor='topleft',
font_size=28,
lines=None,
margin=(8, 3),
label=None,
tabstops=[100],
editable=None,
show_scrollbar=None,
return_callback=None,
esc_callback=None,
alpha=210,
wordwrap=False,
**colors)
(Constructor)
Create a new text box.
-
- Parameters:
x , y , anchor -
The position of the new textbox. anchor should be
one of the pygame rect location attributes, such as
topleft , center , or
midbottom . The textbox will be positioned such that
the given anchor is at (x,y) .
width , height , lines -
The size of the new textbox. width and
height specify the size of the textbox in
pixels.
If height is not specified but lines
is specified, then the textbox will be made tall enough to
display the given number of lines. If neither height
nor lines is specified, and text is not
empty, then the textbox will be made tall enough to display the
text. If neither height nor lines is
specified, and text is empty, then the textbox will
be tall enough to display one line.
If width is not specified, and text
is not empty, then the textbox will be made wide enough to
display the longest line in the given text without wrapping it.
If width is not specified and text is
empty, then a default width will be used.
text -
The initial text to display in the textbox.
font_size -
The font size that should be used by the text box.
margin -
A pair (xmargin, ymargin) , specifying how much
empty room should be left between the text and the textbox's
border on each side. The space specified by xmargin
will also be left between the label (if any) and the text.
label -
A label string that should be displayed to the left of the
textbox.
tabstops -
A list of integers indicating the pixel size of each tabstop.
When the last tabstop is reached, the list cycles back to the
first one.
editable -
If true, then the text box will register key listeners,
allowing the user to edit the text box's contents by typing.
Editing can be turned on and off with the set_editable() method. By default,
editable is true if text is ''.
show_scrollbar -
If true, then a scrollbar will be included on the right side
of the text box. By default, the scrollbar is shown if
either:
-
the textbox is editable and the textbox displays more than
one line of text.
-
the textbox is not editable, and not all text is
displayed.
return_callback -
A callback that should be called with the text when the user
presses return.
esc_callback -
A callback that should be called with the text when the user
presses escape.
alpha -
A value from 0 to 255, indicating how transparent the textbox
should be (0 is transparent, 255 is opaque); or None
for an opaque textbox.
- Overrides:
__builtin__.object.__init__
|