0

Hey guys,

I was wondering if someone might be able to help a newbie out. I'm trying to write a program that randomly flashes either a .gif file on screen or nothing.

Now, I've gotten that working but the trick is I want there to be a short gap between presentations of the .gif file (so that if there are 2 consecutive ones there's a percipitable time gap between them and they actually appear to be two seperate images rather than one long one).

My (failing) approach so far has been to try and use the following:

------------------------------------------------------

def randomcondition ():

    global conditioncount
    global conditionlist
    global randnumber
    global presentationdelay
    global stopgap
    global probdisp
    global number_trials

    if conditioncount < number_trials:     
        
        if randnumber >= probdisp:
            canvas = Canvas (f, width = sw, height = sh)
            canvas.pack ()
            conditioncount += 1
            canvas.after(presentationdelay, clear)
            canvas.after (stopgap)
            randnumber = random ()
            
        elif randnumber <= probdisp:
            canvas = Canvas (f, width = sw, height = sh)
            canvas.create_image(600, 300, image=smiley, anchor=CENTER)
            canvas.pack ()
            conditioncount += 1
            canvas.after(presentationdelay, clear)
            canvas.after (stopgap)
            randnumber = random ()

    if conditioncount == number_trials:
        top.destroy()

-----------------------------------------------------

the second canvas.after () commands in each of the conditions are supposed to be there to pause the program after the screen is blanked and create what looks like a gap, but they don't work and the program works the same even if I take them out.

Can anyone offer any ideas on how else to fix the problem?

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by jlm699
0

you could also do a hard sleep:

import time

time.sleep(1) # 1 second delay in processing
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.