Package pygsear :: Module Widget :: Class TextInput
[show private | hide private]
[frames | no frames]

Class TextInput

    Widget --+            
             |            
        Button --+        
                 |        
object --+       |        
         |       |        
    Sprite --+   |        
             |   |        
      Drawable --+        
                 |        
      SpriteButton --+    
                     |    
        TextButton --+    
                     |    
      SpriteTextButton --+
                         |
                        TextInput


Used to gather text input from the user.
Method Summary
  __init__(self, window, text, prompt, maxLength, length, callback, size, color, border, borderColor, padding, bgColor, inactiveColor, inactiveBgColor, group)
Initialize the TextInput widget.
  activate(self)
  addLetter(self, pygameEvent)
Process the next keypress.
  clicked(self, pygameEvent)
  cursor_left(self)
  cursor_right(self)
  deactivate(self)
  done(self, pygame_event)
return the text_content.
  fire(self, pygameEvent)
  makeButton(self)
  modal(self)
  released(self, pygameEvent)
  set_text(self, text)
Save a copy of the content of the text field and update.
  updateButton(self)
    Inherited from Button
  arm(self)
    Inherited from Widget
  nop(self, arg)
  set_callback(self, callback)
    Inherited from Drawable
bool can_see(self, target, blocking_rects_list)
Performs a los (line of sight) check from the center of the source to the center of the target.
  center(self, x, y, dx, dy)
Align the Drawable in its layer
  clear(self, surface)
Erase sprite to background
bool collide(self, other)
return True if this sprite and other sprite overlap.
Drawable or False collidelist(self, lothers)
return True if this sprite and any in list of others collide.
List collidelistall(self, lothers)
return True if this sprite and any in list of others collide.
  direction(self, point)
return the direction from the sprite to a point
  distance(self, point)
return the distance from the sprite to a point
  draw(self, surface)
Blit image to layer
  get_position(self)
return a copy of the sprite's position
  get_size(self)
return size of sprite's rect.
  move(self)
set position to next position on path
  nudge(self, dx, dy)
Move sprite.
  onscreen(self, slack, **kw)
return True if image is on the screen or layer.
  pause(self)
stop moving along Path
  runPath(self, frames)
call move() continuously
  set_crect(self, crect)
set the collision pygame.Rect used for collision checking.
  set_path(self, path)
set which path to follow
  set_position(self, location, *args)
Move sprite to location.
  set_positionRandom(self, slack)
Move sprite to a random location on screen
  set_size(self, size)
Set size of sprite's rect.
  solid(self, other, move_both)
move sprite so that it does not overlap with other sprite
  stretch(self, dx, dy, size, keepAspectRatio)
Change the size of sprite's image, and rect.
  uclear(self, surface)
clear sprite and update display
  udraw(self, surface)
Draw image and update display.
  unpause(self)
start moving along Path
    Inherited from Sprite
  __repr__(self)
  add(self, *groups)
add(group or list of of groups, ...) add a sprite to container
  add_internal(self, group)
  alive(self)
alive() -> bool check to see if the sprite is in any groups
  groups(self)
groups() -> list of groups list used sprite containers
  kill(self)
kill() remove this sprite from all groups
  remove(self, *groups)
remove(group or list of groups, ...) remove a sprite from container
  remove_internal(self, group)
  update(self, *args)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)
    Inherited from type
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T

Method Details

__init__(self, window=None, text='', prompt='', maxLength=10, length=150, callback=None, size=22, color=(255, 255, 255), border=1, borderColor=(125, 255, 125), padding=5, bgColor=(0, 0, 0), inactiveColor=(195, 195, 195), inactiveBgColor=(95, 95, 95), group=None)
(Constructor)

Initialize the TextInput widget.
Parameters:
window - Layer on which sprite lives.
text - Initial text in the window.
maxLength - Maximum number of characters in input.
length - Width of the text window in pixels.
callback - Function to call when RETURN is pressed.
size - Font size.
color - Text color.
border - Thickness of text window border (0 for no border)
borderColor - Color of window border (if any)
padding - Space between text and edge of window or border.
bgColor - Background color of text window.
inactiveColor - Text color when widget is inactive.
inactiveBgColor - Background color when widget is inactive.
group - Additional group/ groups that should watch for this widget's events.
Overrides:
pygsear.Widget.SpriteTextButton.__init__

addLetter(self, pygameEvent)

Process the next keypress.
Parameters:
pygameEvent - pygame.event.Event. Usually passed in from the pygsear Event handler.

done(self, pygame_event=None)

return the text_content.

If this is triggered from one of the widget's own events (ie K_RETURN), it only returns the contents if the widget is active. Otherwise, if it was called from outside (pygame_event is None) it returns the content no matter what it's state was (active or inactive). This allows another button to call in to the TextInput and force it to trigger its callback.
Parameters:
pygame_event - pygame.Event triggering the call. If this is None, done() must have been called from outside the widget, and so it should just go ahead and callback with its text.

set_text(self, text)

Save a copy of the content of the text field and update.

Since the actual field is padded with spaces when it is rendered, it is necessary to save a copy of the actual contents before going to render.

Generated by Epydoc 2.0 on Sat Dec 9 14:11:19 2006 http://epydoc.sf.net