Re: Text entry

Bruce Sherwood <[email protected]>
Newsgroups gmane.comp.python.visualpython.user
Message-ID <CAFDG03ivRPfX4Xf97jod6r05-cPNo5QtCE9RnK4HGYfXctG6Kg@mail.gmail.com>
There isn't a true text-editing object in VPython. The closest
approximation is this routine found in the documentation on keyboard
events:

from visual import *
prose = label() # initially blank text
while True:
    if scene.kb.keys: # event waiting to be processed?
        s = scene.kb.getkey() # get keyboard info
        if len(s) == 1:
            prose.text += s # append new character
        elif ((s == 'backspace' or s == 'delete') and
                len(prose.text)) > 0:
            prose.text = prose.text[:-1] # erase letter
        elif s == 'shift+delete':
            prose.text = '' # erase all text

Of course there is also the ability to use Python to accept input that
appears in the Python Shell window.

Bruce Sherwood

On Wed, Aug 10, 2011 at 7:25 PM, Dan Aldrich <[email protected]> wrote:
> Is there a text box available in visual to allow user to enter data?
> I saw the text box, but got the impression it was only for display.
>
> Thanks,
> -d

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. 
http://p.sf.net/sfu/wandisco-dev2dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.