Author: bugman Date: Tue Aug 2 14:40:52 2011 New Revision: 14061 URL: http://svn.gna.org/viewcvs/relax?rev=14061&view=rev Log: A timer is now being used to update the gauges of the relax controller. The gauges were previously not pulsing correctly. Modified: branches/gui_testing/gui/controller.py Modified: branches/gui_testing/gui/controller.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/controller.py?rev=14061&r1=14060&r2=14061&view=diff ============================================================================== --- branches/gui_testing/gui/controller.py (original) +++ branches/gui_testing/gui/controller.py Tue Aug 2 14:40:52 2011 @@ -97,6 +97,10 @@ # Initial update of the controller. self.update_controller() + # Create a timer for updating the gauges. + self.timer = wx.Timer(self) + self.Bind(wx.EVT_TIMER, self.handler_timer, self.timer) + # Register functions with the observer objects. status.observers.pipe_alteration.register('controller', self.update_controller) status.observers.auto_analyses.register('controller', self.update_controller) @@ -285,6 +289,22 @@ self.Hide() + def handler_timer(self, event): + """Event handler for the timer. + + @param event: The wx event. + @type event: wx event + """ + + # Pulse. + self.main_gauge.Pulse() + + # Stop the timer and update the gauge. + if not status.exec_lock.locked() and self.timer.IsRunning(): + self.timer.Stop() + self.update_gauge() + + def setup_frame(self): """Set up the relax controller frame. @return: The sizer object. @@ -370,22 +390,34 @@ # Pulse during execution. if status.exec_lock.locked(): - self.main_gauge.Pulse() + # Start the timer. + if not self.timer.IsRunning(): + self.timer.Start(100) + + # Finish. + return # Finished. key = self.analysis_key() if key and status.auto_analysis.has_key(key) and status.auto_analysis[key].fin: + # Stop the timer. + if self.timer.IsRunning(): + self.timer.Stop() + + # Fill the gauge. self.main_gauge.SetValue(100) - # Reset the gauge. - if not status.exec_lock.locked(): - # No key, so reset. - if not key or not status.auto_analysis.has_key(key): - self.main_gauge.SetValue(0) - - # Key present, but analysis not started. - if key and status.auto_analysis.has_key(key) and not status.auto_analysis[key].fin: - self.main_gauge.SetValue(0) + # Gauge is in the initial state, so no need to reset. + if not self.main_gauge.GetValue(): + return + + # No key, so reset. + if not key or not status.auto_analysis.has_key(key): + self.main_gauge.SetValue(0) + + # Key present, but analysis not started. + if key and status.auto_analysis.has_key(key) and not status.auto_analysis[key].fin: + self.main_gauge.SetValue(0) def update_mf(self):