Advertisement
here2share

# progress_bar_by_gradient.py

Jun 5th, 2015
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # progress_bar_by_gradient.py
  2.  
  3. import appuifw,e32,time
  4.  
  5. def empty(rect):
  6.     pass
  7. def draw(rect):
  8.     if not c:
  9.         canvas.clear(0x000000)
  10.         return
  11.  
  12.     canvas.line((i,barWidthA,i,barWidthB),color,width=2)
  13.  
  14.     # frame
  15.     canvas.rectangle((0,barWidthA,X,barWidthB+2),0xffffff)
  16.     time.sleep(0.009) ### Otherwise Too Fast ???
  17.  
  18. ### >>> Additional Python Code <<<
  19.  
  20. def forLight():
  21.     appuifw.e32.reset_inactivity()
  22.     timer.after(10,forLight)
  23.  
  24.  
  25. def exit(): global run; run=0
  26. appuifw.app.exit_key_handler=exit
  27.  
  28. timer=appuifw.e32.Ao_timer()
  29. forLight()
  30.  
  31. appuifw.app.orientation='portrait'
  32. appuifw.app.directional_pad=False
  33. canvas=appuifw.Canvas(redraw_callback=empty)
  34. appuifw.app.body=canvas
  35. X,Y=canvas.size
  36.  
  37. barWidthA=140
  38. barWidthB=barWidthA+19
  39.  
  40. run=1
  41. c=None
  42. color=0x000000
  43. canvas=appuifw.Canvas(redraw_callback=draw)
  44. appuifw.app.body=canvas
  45.  
  46. while run:
  47.     draw(())
  48.     for i in range(X):
  49.         if not run: break
  50.         c=int(((255.0*2)/X)*i)
  51.         if not c > 255:
  52.             # red marker
  53.             color=(255,c,0)
  54.         else:
  55.             # green marker
  56.             c -= 255
  57.             color=(255-c,255,0)
  58.         draw(())
  59.         e32.ao_yield()
  60.     c=None
  61.  
  62. timer.cancel()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement