[Spambayes-checkins] spambayes/Outlook2000/dialogs async_processor.py, 1.7, 1.8

Mark Hammond mhammond at users.sourceforge.net
Sat Sep 6 21:53:16 EDT 2003


Update of /cvsroot/spambayes/spambayes/Outlook2000/dialogs
In directory sc8-pr-cvs1:/tmp/cvs-serv18595

Modified Files:
	async_processor.py 
Log Message:
Handle ranges that don't quite have enough ticks or slightly too many.
Don't use the underlying "tick" methods - just set the pos directly, as
we know it.
This fixes the problem that seemed to stop the progress bar from ever
getting over 80% or so.


Index: async_processor.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/async_processor.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** async_processor.py	1 Sep 2003 05:34:19 -0000	1.7
--- async_processor.py	7 Sep 2003 03:53:13 -0000	1.8
***************
*** 13,16 ****
--- 13,17 ----
      True, False = 1, 0
  
+ verbose = 0
  
  IDC_START = 1100
***************
*** 50,54 ****
              win32api.PostMessage(self.hprogress, commctrl.PBM_SETSTEP, 1, 0)
              win32api.PostMessage(self.hprogress, commctrl.PBM_SETPOS, 0, 0)
-             self.current_control_tick = 0
  
          self.current_stage += 1
--- 51,54 ----
***************
*** 59,68 ****
  
      def set_max_ticks(self, m):
          self._next_stage()
-         self.current_stage_tick = 0
          self.current_stage_max = m
  
      def tick(self):
!         self.current_stage_tick += 1
          # Calc how far through this stage.
          this_prop = float(self.current_stage_tick) / self.current_stage_max
--- 59,73 ----
  
      def set_max_ticks(self, m):
+         # skip to the stage.
          self._next_stage()
          self.current_stage_max = m
+         self.current_stage_tick = -1 # ready to go to zero!
+         # if earlier stages stopped early, skip ahead.
+         self.tick()
  
      def tick(self):
!         if self.current_stage_tick < self.current_stage_max:
!             # Don't let us go beyond our stage max
!             self.current_stage_tick += 1
          # Calc how far through this stage.
          this_prop = float(self.current_stage_tick) / self.current_stage_max
***************
*** 75,83 ****
          # user knows the process has actually started.)
          control_tick = max(1,int(total_prop * self.total_control_ticks))
!         #print "Tick", self.current_stage_tick, "is", this_prop, "through the stage,", total_prop, "through the total - ctrl tick is", control_tick
!         while self.current_control_tick < control_tick:
!             self.current_control_tick += 1
!             #print "ticking control", self.current_control_tick
!             win32api.PostMessage(self.hprogress, commctrl.PBM_STEPIT, 0, 0)
  
      def _get_stage_text(self, text):
--- 80,86 ----
          # user knows the process has actually started.)
          control_tick = max(1,int(total_prop * self.total_control_ticks))
!         if verbose:
!             print "Tick", self.current_stage_tick, "is", this_prop, "through the stage,", total_prop, "through the total - ctrl tick is", control_tick
!         win32api.PostMessage(self.hprogress, commctrl.PBM_SETPOS, control_tick)
  
      def _get_stage_text(self, text):
***************
*** 237,240 ****
--- 240,244 ----
  
  if __name__=='__main__':
+     verbose = 1
      # Test my "multi-stage" code
      class HackProgress(_Progress):
***************
*** 243,250 ****
              self.dlg = None
              self.stopping = False
!             self.total_control_ticks = 100
              self.current_stage = 0
              self.set_stages( (("", 1.0),) )
  
      p = HackProgress()
      p.set_max_ticks(10)
--- 247,255 ----
              self.dlg = None
              self.stopping = False
!             self.total_control_ticks = 40
              self.current_stage = 0
              self.set_stages( (("", 1.0),) )
  
+     print "Single stage test"
      p = HackProgress()
      p.set_max_ticks(10)
***************
*** 252,255 ****
--- 257,261 ----
          p.tick()
  
+     print "First stage test"
      p = HackProgress()
      stages = ("Stage 1", 0.2), ("Stage 2", 0.8)
***************
*** 260,265 ****
          p.tick()
      # Do stage 2
!     p.set_max_ticks(1000)
!     for i in range(1000):
          p.tick()
      print "Done!"
--- 266,292 ----
          p.tick()
      # Do stage 2
!     p.set_max_ticks(20)
!     for i in range(20):
!         p.tick()
!     print "Second stage test"
!     p = HackProgress()
!     stages = ("Stage 1", 0.9), ("Stage 2", 0.1)
!     p.set_stages(stages)
!     p.set_max_ticks(10)
!     for i in range(7): # do a few less just to check
!         p.tick()
!     p.set_max_ticks(2)
!     for i in range(2):
!         p.tick()
!     print "Third stage test"
!     p = HackProgress()
!     stages = ("Stage 1", 0.9), ("Stage 2", 0.1)
!     p.set_stages(stages)
!     p.set_max_ticks(300)
!     for i in range(313): # do a few more just to check
!         p.tick()
!     p.set_max_ticks(2)
!     for i in range(2):
          p.tick()
+     
      print "Done!"





More information about the Spambayes-checkins mailing list