Read the contents of the memory-mapped file and update the ui if necessary. If the same counters are present in the file as before we just update the existing labels. If any counters have been added or removed we scrap the existing ui and draw a new one.
(self)
| 135 | self.shared_mmap.close() |
| 136 | |
| 137 | def UpdateCounters(self): |
| 138 | """Read the contents of the memory-mapped file and update the ui if |
| 139 | necessary. If the same counters are present in the file as before |
| 140 | we just update the existing labels. If any counters have been added |
| 141 | or removed we scrap the existing ui and draw a new one. |
| 142 | """ |
| 143 | changed = False |
| 144 | counters_in_use = self.data.CountersInUse() |
| 145 | if counters_in_use != len(self.ui_counters): |
| 146 | self.RefreshCounters() |
| 147 | changed = True |
| 148 | else: |
| 149 | for i in range(self.data.CountersInUse()): |
| 150 | counter = self.data.Counter(i) |
| 151 | name = counter.Name() |
| 152 | if name in self.ui_counters: |
| 153 | value = counter.Value() |
| 154 | ui_counter = self.ui_counters[name] |
| 155 | counter_changed = ui_counter.Set(value) |
| 156 | changed = (changed or counter_changed) |
| 157 | else: |
| 158 | self.RefreshCounters() |
| 159 | changed = True |
| 160 | break |
| 161 | if changed: |
| 162 | # The title of the window shows the last time the file was |
| 163 | # changed. |
| 164 | self.UpdateTime() |
| 165 | self.ScheduleUpdate() |
| 166 | |
| 167 | def UpdateTime(self): |
| 168 | """Update the title of the window with the current time.""" |
no test coverage detected