PDA

View Full Version : Timed changing message on screen


Saz
06-15-2009, 06:00 AM
Hi,

I'm trying to get a 'stop' message appear on the screen 10 seconds into the program, which waits for a second and then changes to 'go'. I've had various attempts and whilst I can get the intial message up (whether it starts off as go or appears at 10s in as stop), it won't change over to the other message.

This is one example of code used:


#Stop and go message
text_go=vizinfo.add('GO')
text_go.translate(.5, .9)
text_go.fontSize (35)

def stopSign():

text_go.message('STOP')
viz.waittime (1)
text_go.message ('GO')
vizact.ontimer (10,stopSign)


and this is another:



def stopGo():
Wait 10 secs
viz.waittime(10)
text.message( 'STOP' )
#Wait 1 sec
viz.waittime(1)
text.message( 'GO' )
viz.director( stopGo )


which also fails to work, any ideas on what I'm doing wrong?

Jeff
06-15-2009, 01:28 PM
you could use the following
#Stop and go message
text_go=vizinfo.add('GO')
text_go.translate(.5, .9)

def stopSign():

text_go.message('STOP')
vizact.ontimer2(1,0, text_go.message,'GO')

vizact.ontimer(10,stopSign)

your first example uses viz.waittime but its not in a director function

Saz
06-16-2009, 04:56 AM
Cheers Jeff - you're a star! I have got another problem though - all of a sudden the output data will not write to the specified file - it was fine and then suddenly stopped working. The code I have is as follows:

directory = 'Y:\backup\Vizard30\resources\road'
subjectd = 'speed_.txt' + str(subject)
filename = directory+subjectd
file = open(filename, 'w')

def mytimer (num):

out = (str(round(speedm,1)) + '\n')
file.write(out)
file.flush()
print out
viz.callback( viz.TIMER_EVENT, mytimer )
viz.starttimer( 0, 0.25, viz.FOREVER )


but now this message appears:
Traceback (most recent call last):
File "<string>", line 11, in ?
File "roadldstop.py", line 167, in ?
file = open(filename, 'w')
IOError: [Errno 2] No such file or directory: 'Y:\x08ackup\\Vizard30\resources\roadspeed_.txt222 2'

I know the path exists so is this message because it's trying to create a temporary file when outputting the data?

Saz
06-17-2009, 03:14 AM
No worries Jeff - sorted it out and now working :)