Author: ks156
Date: 2009-03-11 13:59:55 +0100 (Wed, 11 Mar 2009)
New Revision: 3952

Modified:
   
software_suite_v2/tuxware/installers/unix/branches/refactoring/misc/progressBar.py
   
software_suite_v2/tuxware/installers/unix/branches/refactoring/tux_software_updater.py
Log:
* Improved the progress bar :
  - the title and the unit can now be specified. The size is automatically
    computed by the init function, and fit a 80 column display.


Modified: 
software_suite_v2/tuxware/installers/unix/branches/refactoring/misc/progressBar.py
===================================================================
--- 
software_suite_v2/tuxware/installers/unix/branches/refactoring/misc/progressBar.py
  2009-03-11 12:57:03 UTC (rev 3951)
+++ 
software_suite_v2/tuxware/installers/unix/branches/refactoring/misc/progressBar.py
  2009-03-11 12:59:55 UTC (rev 3952)
@@ -1,21 +1,33 @@
 #!/usr/bin/python
 __steps = 0
 __progress = 0.0
+__title = ""
+__unit = ""
+__prog_size = 0
 
-def initProgressBar(steps):
+def initProgressBar(steps, title, unit):
     global __steps
     global __progress
-    #print '\033[sProgression : [\033[57C] 0%\033[u',
-    __steps = 57.0 / float(steps)
+    global __title
+    global __unit
+    global __prog_size
+
+    #             TTY - TITLE - UNIT - MINIMIM SIZE 
+    __prog_size = 80 - len(title) - len(unit) - 12
+    __title = title
+    __unit = unit
+    __steps = __prog_size / float(steps)
     __progress = 0
 
 def setProgressBar(percent):
     global __progress
-    progress = ((float(percent) * 57.0) / 100.0)
+    global __prog_size
+    progress = ((float(percent) * __prog_size) / 100.0)
 
 def getProgressBar():
     global __progress
-    return ((float (__progress) * 100.0) / 57.0)
+    global __prog_size
+    return ((float (__progress) * 100.0) / __prog_size)
 
 def incProgressBar():
     global __steps
@@ -25,5 +37,9 @@
     __strokeProgressBar(percent, __progress)
 
 def __strokeProgressBar(percent, progress):
-    print 'Progression : [\033[s'\
-            +"#"*int(progress)+'\033[u\033[56C] '+"%.0f"%percent+'%\033[1A'
+    global __title
+    global __unit
+    global __prog_size
+    print "%s : [\033[s"%__title \
+            +"#"*int(progress)+"\033[u\033[%dC] "%__prog_size \
+            +"%.0f"%percent+"%s\033[1A"%__unit

Modified: 
software_suite_v2/tuxware/installers/unix/branches/refactoring/tux_software_updater.py
===================================================================
--- 
software_suite_v2/tuxware/installers/unix/branches/refactoring/tux_software_updater.py
      2009-03-11 12:57:03 UTC (rev 3951)
+++ 
software_suite_v2/tuxware/installers/unix/branches/refactoring/tux_software_updater.py
      2009-03-11 12:59:55 UTC (rev 3952)
@@ -76,7 +76,7 @@
         for service in processToKillList:
             os.system("pkill -f %s"%service)
 
-        initProgressBar(len(toInstall))
+        initProgressBar(len(toInstall), 'Download', '%')
         # Install or update the new software
         for item in toInstall:
             incProgressBar()


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to