def set_curframe(self, a): if self.selected is not None: i, dti = self.find_ti_pos(self.selected) if i < len(self.keyFrames): if self.min <= a <= self.max: self.keyFrames[i].a = a self.select(self.selected) self.parent.set_servo() self.mark_redraw() else: warn("angle=%d out of range(%s)" %(a, (self.min, self.max)))
def save(self, filename, remember=True): servoc = self.servoc try: if os.path.exists(filename): # file exist, backup self.backup_file(filename) except IOError as e: warn('%r' % e) try: data = self.gen_save_data() with open(filename, 'wb') as f: cPickle.dump(data, f, -1) if remember: self.lastSave = filename self.lastSaveData = data self.write_session() except Exception as ex: raise SaveLoadError(ex) hint('save data to file "%s"' % filename)
def cb_angle(self): # v: the new input value v = self.input_angle.text servoc = self.servoc servo = servoc.servos[servoc.actived] try: v = int(v) if servo.selected is not None: i, dti = servo.find_ti_pos(servo.selected) if i < len(servo.keyFrames) and dti == 0: if servo.min <= v <= servo.max: servo.keyFrames[i].a = v servo.mark_redraw() servo.select(servo.selected) else: warn("angle=%d out of range(%s)" % (v, (servo.min, servo.max))) else: warn("cannot set a non-key frame") except Exception as ex: warn(str(ex)) self.input_angle.text = ""