Package pajammin :: Package display :: Package ui :: Module textbox :: Class TextBox
[show private | hide private]
[frames | no frames]

Type TextBox

  object --+    
           |    
ScreenWidget --+
               |
              TextBox

Known Subclasses:
InputLine

A screen widget for displaying and editing text.
Method Summary
  __init__(self, x, y, width, height, text, anchor, font_size, lines, margin, label, tabstops, editable, show_scrollbar, return_callback, esc_callback, alpha, wordwrap, **colors)
Create a new text box.
  draw(self, screen, duration)
Draw this widget to the screen.
  hide(self)
  insert(self, text)
Insert text at the cursor.
  move(self, dx, dy)
  move_to(self, x, y, anchor)
  set_background(self, color, alpha)
  set_cursor(self, i, j)
  set_editable(self, enable)
  set_text(self, text)
  show(self)
  text(self)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
Return hash(x)...
  __new__(T, S, ...)
Return a new object with type S, a subtype of T...
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
Return repr(x)...
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
Return str(x)...

Instance Variable Summary
  layer: An integer indicating the order in which the widget should be drawn to the screen, relative to other widgets.
    Inherited from ScreenWidget
bool hidden: If true, then the screen widget will not be drawn.

Class Variable Summary
dict color = {'cursor': (0, 0, 128), 'text': (0, 0, 0), 'bord...
int DEFAULT_WIDTH = 300                                                                   
int SCROLLBAR_WIDTH = 14                                                                    
str SHIFTED = '                                 !"#$%&"()*+<...
str UNSHIFTED = '                                 !"#$%&\'()...

Method Details

__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__

draw(self, screen, duration)

Draw this widget to the screen.
Parameters:
screen - The screen surface.
duration - The amount of time that has elapsed since the last call to draw, in msec.
Returns:
A pygame Rect indicating what area of the screen has been modified by this draw operation.
Overrides:
pajammin.display.engine.ScreenWidget.draw (inherited documentation)

hide(self)

insert(self, text)

Insert text at the cursor. Currently, can't contain a newline.

move(self, dx, dy)

move_to(self, x, y, anchor='topleft')

set_background(self, color, alpha=None)

set_cursor(self, i, j)

set_editable(self, enable=True)

set_text(self, text)

show(self)

text(self)


Instance Variable Details

layer

An integer indicating the order in which the widget should be drawn to the screen, relative to other widgets. Widgets with higher layer numbers will be drawn later.
Value:
100                                                                   

Class Variable Details

color

Type:
dict
Value:
{'background': (255, 255, 255),
 'border': (0, 0, 0),
 'cursor': (0, 0, 128),
 'label': (255, 255, 255),
 'text': (0, 0, 0)}                                                    

DEFAULT_WIDTH

Type:
int
Value:
300                                                                   

SCROLLBAR_WIDTH

Type:
int
Value:
14                                                                    

SHIFTED

Type:
str
Value:
'                                 !"#$%&"()*+<_>?)!@#$%^&*(::<+>?@ABCD\
EFGHIJKLMNOPQRSTUVWXYZ{|}^_~ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~ '           

UNSHIFTED

Type:
str
Value:
'                                 !"#$%&\'()*+,-./0123456789:;<=>?@ABC\
DEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ '