LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   [python] print "\033[5;",x,"H=>" (http://www.linuxquestions.org/questions/programming-9/%5Bpython%5D-print-%5C033%5B5%3B-x-h%3D-399750/)

datbenik 01-05-2006 05:27 AM

[python] print "\033[5;",x,"H=>"
 
I'm trying to make a progress bar or something like that. It doesn't work actually. My script (python):
Code:

import os
os.system("clear")
x =1
while x<20:
        print "\033[5;",x,"H=>"
        x = x+1

The result:
Code:

[5; 1 H=>
[5; 2 H=>
[5; 3 H=>
[5; 4 H=>
[5; 5 H=>
[5; 6 H=>
[5; 7 H=>
[5; 8 H=>
[5; 9 H=>
[5; 10 H=>
[5; 11 H=>
[5; 12 H=>
[5; 13 H=>
[5; 14 H=>
[5; 15 H=>
[5; 16 H=>
[5; 17 H=>
[5; 18 H=>
[5; 19 H=>

How can i fix this?

jlliagre 01-05-2006 06:12 AM

Try that:
Code:

import os
import sys;
import time
os.system("clear")
x=1
while x<20:
  sys.stdout.write("\033[5;"+str(x)+"H=>");
  sys.stdout.flush();
  time.sleep(1);
  x=x+1



All times are GMT -5. The time now is 12:51 PM.