[visionegg] Re: collecting keyboard input
- From: Mark Halko <mhalko@xxxxxx>
- To: visionegg@xxxxxxxxxxxxx
- Date: Tue, 9 May 2006 18:04:43 -0400
A quick example (edited displayText.py):
#!/usr/bin/env python
"""Display text strings."""
import VisionEgg
VisionEgg.start_default_logging(); VisionEgg.watch_exceptions()
from VisionEgg.Core import *
from VisionEgg.FlowControl import Presentation
from VisionEgg.Text import *
import sys
screen = get_default_screen()
screen.parameters.bgcolor = (0.0,0.0,1.0) # background blue (RGB)
text =
Text(text="",anchor='center',position=(screen.size[0]/2,screen.size[1]/
2))
viewport = Viewport(screen=screen,size=screen.size,stimuli=[text])
def keydown(event) :
global text
if event.key == pygame.locals.K_ESCAPE :
sys.exit()
elif event.key == pygame.locals.K_RETURN :
print text.parameters.text
text.parameters.text=""
elif event.key == pygame.locals.K_BACKSPACE :
text.parameters.text=text.parameters.text[:-1]
else :
text.parameters.text+=event.unicode
p = Presentation(go_duration=('forever',),viewports=[viewport])
p.parameters.handle_event_callbacks = [(pygame.locals.QUIT, sys.exit),
(pygame.locals.KEYDOWN,
keydown)]
p.go()
On May 9, 2006, at 4:19 PM, Alessandro Gagliardi wrote:
I haven't touched Vision Egg yet, so forgive me my ignorant questions
but: how hard would it be to echo that input on the screen? I ask
because in PyEPL (which I have been using), to repeatedly update the
screen with every key press is a bit of a pain. It's not like you can
have a textbox with the input fed from the keyboard, like you might be
able to in other systems. How is it in Vision Egg? (And for the
record, I did take a look at the documentation on the website and I
didn't see anything about tracking key presses. Though perhaps I
didn't look hard enough.)
Thanks!
-Alessandro
On 5/9/06, Chao Tang <tang@xxxxxxxxxxx> wrote:Hi,
You may use pygame.event to get what you want...see code snap bellow.
import pygame
# get one key press
for event in pygame.event.get():
# event.type and event.key are ready for you to use
if event.type == pygame.KEYDOWN:
...
if event.type == pygame.KEYUP:
...
HTH.
Chao
-----Original Message-----
From: visionegg-bounce@xxxxxxxxxxxxx
[mailto:visionegg-bounce@xxxxxxxxxxxxx]On Behalf Of Alessandro
Gagliardi
Sent: Tuesday, May 09, 2006 3:09 PM
To: visionegg@xxxxxxxxxxxxx
Subject: [visionegg] collecting keyboard input
Hello Vision Egg users,
I'm currently designing an experiment in which I want to collect
keyboard input from a participant typing one word answers to
questions. Obviously, I would like their input echoed on the
screen. Is there an easy way to do this with Vision Egg? There is
no way in the software that I'm currently using, so I'm thinking of
switching.
Thanks in advance,
--
Alessandro Gagliardi
Integrative Neuroscience
Rutgers University
alessandro@xxxxxxxxxxxxxx
--
Alessandro Gagliardi
Integrative Neuroscience
Rutgers University
alessandro@xxxxxxxxxxxxxx
=====================================The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
- References:
- [visionegg] collecting keyboard input
- From: Alessandro Gagliardi
- [visionegg] Re: collecting keyboard input
- From: Chao Tang
- [visionegg] Re: collecting keyboard input
- From: Alessandro Gagliardi
Other related posts:
- » [visionegg] collecting keyboard input
- » [visionegg] Re: collecting keyboard input
- » [visionegg] Re: collecting keyboard input
- » [visionegg] Re: collecting keyboard input
- » [visionegg] Re: collecting keyboard input
- » [visionegg] Re: collecting keyboard input
Thanks! -Alessandro
On 5/9/06, Chao Tang <tang@xxxxxxxxxxx> wrote:Hi,
You may use pygame.event to get what you want...see code snap bellow. import pygame # get one key press for event in pygame.event.get(): # event.type and event.key are ready for you to use if event.type == pygame.KEYDOWN: ... if event.type == pygame.KEYUP: ... HTH.
Chao
-----Original Message-----
From: visionegg-bounce@xxxxxxxxxxxxx [mailto:visionegg-bounce@xxxxxxxxxxxxx]On Behalf Of Alessandro Gagliardi
Sent: Tuesday, May 09, 2006 3:09 PM
To: visionegg@xxxxxxxxxxxxx
Subject: [visionegg] collecting keyboard input
Hello Vision Egg users,
I'm currently designing an experiment in which I want to collect keyboard input from a participant typing one word answers to questions. Obviously, I would like their input echoed on the screen. Is there an easy way to do this with Vision Egg? There is no way in the software that I'm currently using, so I'm thinking of switching.
Thanks in advance, -- Alessandro Gagliardi Integrative Neuroscience Rutgers University alessandro@xxxxxxxxxxxxxx
-- Alessandro Gagliardi Integrative Neuroscience Rutgers University alessandro@xxxxxxxxxxxxxx
- [visionegg] collecting keyboard input
- From: Alessandro Gagliardi
- [visionegg] Re: collecting keyboard input
- From: Chao Tang
- [visionegg] Re: collecting keyboard input
- From: Alessandro Gagliardi