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?

Recommended Answers

All 2 Replies

try wx.python and there is timer called wx.Timer for your timming

you could also do a hard sleep:

import time

time.sleep(1) # 1 second delay in processing
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.