pygame is
Python
Simple DirectMedia Layer
 
 
pygame.org is
Site Swing
Form

Form - 2.0

josmiley / Luke spywoker (mutualaccount)

Tags:

Description

a class that allows you to edit text
it manages mouse insertion and some controls keys.

new version, completely rewritten
function 'ask' has become a 'class' for more flexibility and is now called Form.
sorry, not yet documented ...

Changes

new version, new concept
function 'ask' has become a 'class' for more flexibility and is now called Form.
The Form class has 3 attributes:
cursor = '|'
cursor_color = 150,150,150
font = font.Font (font.get_default_font (), 20)

and is defined as:
Form (POS, LENGTH, FONT = None, MAXLEN = 0, COLOR = (200,200,200))
POS <== (x, y)
LENGTH <== width in pix
FONT <== pygame.font object (Form.font default)
MAXLEN <== size of the string in characters 0 == unlimited
COLOR <== text color

Form object has 4 ATTRIBUTES:
RECTANGLE <== screen area that contains the text
FONT <== Font object
MAXLEN <== size of the string in characters 0 == unlimited

some properties:
INDEX <== reads and changes the cursor position
OUTPUT <== reads and modifies the text
CURSOR <== reads and changes the the character cursor
CURSOR_COLOR <== reads and changes the cursor color
COLOR <== reads and modifies the text color

and some methods:
clear(): clear OUTPUT
hide_cursor()
show_cursor()
init() : initializes the display, must be called at least once, and before update()
update(pygame.event) : must be called recursively

For the moment there is only one function provided:
sheet (Form sequence) ==> None

soon, more documentation and function

Links

Home Page: http://joel-murielle.perso.sfr.fr
Source: http://joel-murielle.perso.sfr.fr/ask.py

Screenshot


click to view original size

Releases

Form - 4.0 - Mar 29, 2011
Form - 3.2 - Mar 21, 2011
Form - 3.1 - Mar 21, 2011
Form - 3.0 - Mar 20, 2011
Form - 2.2 - Mar 15, 2011
Form - 2.1 - Mar 11, 2011
Form - 2.0 - Mar 10, 2011
Form - 1.1 - Jul 8, 2010
Form - 1.0 - Jul 5, 2010

Pygame.org account Comments

If you wish to leave a comment with your pygame.org account, please sign in first.

December 29, 2010 1:43pm - Robert Leachman - nickname: (quazar) - 5/5
Thanks, works like a champ, I plan to use this. For anyone interested here's the patch to respond to the quit event... also only letters and numbers:
$ diff -wc ask_1.1.py ask_hack.py
*** ask_1.1.py 2010-12-29 10:37:40.000000000 -0800
--- ask_hack.py 2010-12-29 10:40:40.000000000 -0800
***************
*** 1,3 ****
--- 1,4 ----
+ import sys
from pygame import display,init,font,key,Rect,event
from pygame.locals import *
font.init()
***************
*** 64,69 ****
--- 65,71 ----
elif ev.key == K_ESCAPE: return None
elif ev.key == K_TAB: pass
elif (len(INPUT)-1<MAXLEN if MAXLEN else 1):
+ if (ev.key > 96 and ev.key < 123) or (ev.key > 47 and ev.key < 58):
INPUT.insert(INDEX,ev.unicode)
INDEX += 1
C = gen.next()
***************
*** 78,83 ****
--- 80,87 ----
C = gen.next()
elif Rect(ev.pos,(0,0)).colliderect(RECTANGLE):
event.post(event.Event(KEYDOWN,{'scancode': 115, 'key': 279, 'unicode': u'', 'mod': 4096}))
+ elif ev.type == QUIT:
+ sys.exit()
SCREEN.blit(BG,POS,(POS,RECTANGLE.size))
display.update((POS,RECTANGLE.size))
key.set_repeat(*repeat)
Thanks again Josmiley!
spotlight

 
our projects
pygame.org welcomes all python game, art, music, sound, video and multimedia projects. If they use pygame or not.
 
recent releases
Jul 28, 2014

Jul 22, 2014

Jul 21, 2014

Jul 20, 2014

Jul 19, 2014

Jul 15, 2014

Jul 10, 2014

Jul 9, 2014

Jun 27, 2014



Jun 24, 2014

... more!
 
for pygame related questions, comments, and suggestions, please see help (lists, irc)