Commits

Samuel Ytterbrink committed d90e328

Took code in the update method of the TKGUI class which handled getting state (color/text) to functions that returned the state instead .

They should probably end up in there own classes...

Comments (0)

Files changed (1)

         )
         self.status_bar.pack(expand=1, fill="both")
 
-    def update(self):
-        """updates the tk gui"""
+    def _update_and_get_color(self):
+        "Calculate the current color and trigger pulse"
         self.color_picker.set_result(
             self.pytddmon.total_tests_passed,
             self.pytddmon.total_tests_run,
         light, color = self.color_picker.pick()
         rgb = self.color_picker.translate_color(light, color)
         self.color_picker.pulse()
+        return rgb
+
+    def _get_text(self):
+        "Calculates the text to show the user(passed/total or Error!)"
         if self.pytddmon.total_tests_run.imag!=0:
             text = "?ERROR"
         else:
                 self.pytddmon.total_tests_passed,
                 self.pytddmon.total_tests_run
             )
+        return text
 
+    def update(self):
+        """updates the tk gui"""
+        rgb = self._update_and_get_color()
+        text = self._get_text()
         self.button.update(text, rgb)
-        self.root.configure(
-            bg=rgb,
-        )
+        self.root.configure(bg=rgb)
         self.update_status(self.pytddmon.get_status_message())
-
+    
         if self.pytddmon.change_detected:
             self.update_text_window()