A counter in the ui.
| 269 | |
| 270 | |
| 271 | class UiCounter(object): |
| 272 | """A counter in the ui.""" |
| 273 | |
| 274 | def __init__(self, var, format): |
| 275 | """Creates a new ui counter. |
| 276 | |
| 277 | Args: |
| 278 | var: the Tkinter string variable for updating the ui |
| 279 | format: the format string used to format this counter |
| 280 | """ |
| 281 | self.var = var |
| 282 | self.format = format |
| 283 | self.last_value = None |
| 284 | |
| 285 | def Set(self, value): |
| 286 | """Updates the ui for this counter. |
| 287 | |
| 288 | Args: |
| 289 | value: The value to display |
| 290 | |
| 291 | Returns: |
| 292 | True if the value had changed, otherwise False. The first call |
| 293 | always returns True. |
| 294 | """ |
| 295 | if value == self.last_value: |
| 296 | return False |
| 297 | else: |
| 298 | self.last_value = value |
| 299 | self.var.set(self.format % value) |
| 300 | return True |
| 301 | |
| 302 | |
| 303 | class SharedDataAccess(object): |
no outgoing calls
no test coverage detected
searching dependent graphs…