Пример #1
0
    def create_profile(self):
        new_profile = Profile('profile #' + str(len(self.profiles) + 1))
        current_index = self.cbxProfiles.currentIndex()

        new_profile.lock_to_lock = self.profiles[current_index].lock_to_lock
        new_profile.bump_to_bump = self.profiles[current_index].bump_to_bump
        new_profile.invert_force = self.profiles[current_index].invert_force
        new_profile.max_force = self.profiles[current_index].max_force
        new_profile.use_reconstruction = self.profiles[
            current_index].use_reconstruction
        new_profile.smoothing_level = self.profiles[
            current_index].smoothing_level
        new_profile.friction = self.profiles[current_index].friction
        new_profile.damping = self.profiles[current_index].damping
        new_profile.inertia = self.profiles[current_index].inertia
        self.profiles.append(new_profile)

        self.cbxProfiles.clear()
        for profile in self.profiles:
            self.cbxProfiles.addItem(profile.name)
        self.cbxProfiles.setCurrentIndex(len(self.profiles) - 1)
        self.select_profile(len(self.profiles) - 1)
        self.save_current_profile_internally()
        if len(self.profiles) > 1:
            self.btnDelete.setEnabled(True)
Пример #2
0
 def load_profiles_from_file(self):
     self.profiles.clear()
     tree = ET.parse('profiles.xml')
     root = tree.getroot()
     for prof in root:
         profile = Profile(prof.attrib['name'])
         profile.lock_to_lock = float(prof[0].text)
         profile.bump_to_bump = float(prof[1].text)
         profile.invert_force = bool(prof[2].text == 'True')
         profile.max_force = float(prof[3].text)
         profile.use_reconstruction = bool(prof[4].text == 'True')
         profile.smoothing_level = int(prof[5].text)
         profile.friction = float(prof[6].text)
         profile.damping = float(prof[7].text)
         profile.inertia = float(prof[8].text)
         self.profiles.append(profile)