def update(self): try: val = getattr(self.obj, self.attr) except AttributeError: return 0 # Not readable => do not update ! self.scale.configure(label = song.duration_label(val)) if val in (9, 18, 36, 72, 144, 288, 576): val = int(val / 1.5) self.doted.set(1) else: self.doted.set(0) if val in (4, 8, 16, 32, 64, 128, 256): val = int(val * 1.5) self.triplet.set(1) else: self.triplet.set(0) self.scale.set({ 0: 0, 6 : 0, 12 : 1, 24: 2, 48 : 3, 96 : 4, 192 : 5, 384 : 6 }[val]) return 1
def validate(self, event = None): val = 6 * 2 ** self.scale.get() if self.doted .get(): val = int(val * 1.5) elif self.triplet.get(): val = int(val / 1.5) self.set_value(val) self.scale.configure(label = song.duration_label(val))