Joe T. Boka
Joe T. Boka

Reputation: 6581

Time sleep in Web2py

I try to use time.sleep in Web2py. Let's say, if I want a text to appear 5 seconds after an other text.

In the Controller:

import time

def time_test():
    t = time.sleep(5)
    return locals()

In the View:

<h1>Text 1</h1>
{{=t}}
<h1>Text 2</h1>

But this just makes the page load 5 seconds later.

In Python it works like this:

import time
print "Image 1"
time.sleep(5)
print "Image 2"

but I would like to learn how to do this in Web2py

Upvotes: 0

Views: 258

Answers (1)

Rafal
Rafal

Reputation: 11

Basically, you can do this the way like Lukas Graf said but if it's just a matter of showing text with a five second delay in a web2py page, then you don't really need the web2py functionality for it. You can just use a client side script like javascript. You render a page with web2py including a javascript that will show a certain text with a 5 second delay. This is the more standard way to achieve this, web2py or not.

Upvotes: 1

Related Questions