Curses programming, threads?

Bartlomiej Rymarski bart at oceanic.wsisiz.edu.pl
Fri Dec 3 05:34:05 EST 2004


Hello, 

I'm writing this little program, and I've came across a function
that I need to call. Since the execution of the function takes a 
real long time I want to put a timer, or an animated 'loading' 
screen (it would be best if it was a progressbar). The questions is
how to make two commands to run at the same time. 

I'm talking about a function which (for example) is connecting to
the database, and while it's connecting I would like to display a
nice loading animation. It could be a ascii sequence like this:
 [/] [-] [\] [|] [/] [-] [\] [|]

I could write a function like this:

#v+
def function:
	print "[/]"
	command
	print "[-]"
	command
	print "[\]"
	command
	...
#v-

But is this really the way other programs work? I don't think so.
And they don't use threads AFAIK. How can I accomplish something 
like this?

It would be best if I could operate with like this:

#v+
def function:
	do loader() while
		connect_db()
#v-

And the loader() function would run in a loop until connect_db() is 
is finished. Is that possible in python? Or are there any other,
better ways to do it?

Thanks a lot.

Regards,

-- 
Bartek Rymarski <bart at wsisiz.edu.pl>
$ %blow
bash: fg: %blow: no such job



More information about the Python-list mailing list