Beispiel #1
0
	def delete(self):
		"Delete the selection of a listbox setting."
		self.profileListboxSetting.setToDisplay()
		self.profileListboxSetting.listSetting.setValueToFolders()
		if self.profileListboxSetting.value not in self.profileListboxSetting.listSetting.value:
			return
		lastSelectionIndex = 0
		currentSelectionTuple = self.profileListboxSetting.listbox.curselection()
		if len(currentSelectionTuple) > 0:
			lastSelectionIndex = int(currentSelectionTuple[0])
		else:
			print('No profile is selected, so no profile will be deleted.')
			return
		craftTypeName = self.profileListboxSetting.listSetting.craftTypeName
		settings.deleteDirectory(archive.getProfilesPath(craftTypeName), self.profileListboxSetting.value)
		settings.deleteDirectory(settings.getProfilesDirectoryInAboveDirectory(craftTypeName), self.profileListboxSetting.value)
		self.profileListboxSetting.listSetting.setValueToFolders()
		if len(self.profileListboxSetting.listSetting.value) < 1:
			defaultSettingsDirectory = archive.getProfilesPath(os.path.join(craftTypeName, self.profileListboxSetting.defaultValue))
			archive.makeDirectory(defaultSettingsDirectory)
			self.profileListboxSetting.listSetting.setValueToFolders()
		lastSelectionIndex = min(lastSelectionIndex, len(self.profileListboxSetting.listSetting.value) - 1)
		self.profileListboxSetting.value = self.profileListboxSetting.listSetting.value[lastSelectionIndex]
		self.profileListboxSetting.setStateToValue()
		self.no()
 def delete(self):
     "Delete the selection of a listbox setting."
     self.profileListboxSetting.setToDisplay()
     self.profileListboxSetting.listSetting.setValueToFolders()
     if self.profileListboxSetting.value not in self.profileListboxSetting.listSetting.value:
         return
     lastSelectionIndex = 0
     currentSelectionTuple = self.profileListboxSetting.listbox.curselection(
     )
     if len(currentSelectionTuple) > 0:
         lastSelectionIndex = int(currentSelectionTuple[0])
     else:
         print('No profile is selected, so no profile will be deleted.')
         return
     craftTypeName = self.profileListboxSetting.listSetting.craftTypeName
     settings.deleteDirectory(archive.getProfilesPath(craftTypeName),
                              self.profileListboxSetting.value)
     settings.deleteDirectory(
         settings.getProfilesDirectoryInAboveDirectory(craftTypeName),
         self.profileListboxSetting.value)
     self.profileListboxSetting.listSetting.setValueToFolders()
     if len(self.profileListboxSetting.listSetting.value) < 1:
         defaultSettingsDirectory = archive.getProfilesPath(
             os.path.join(craftTypeName,
                          self.profileListboxSetting.defaultValue))
         archive.makeDirectory(defaultSettingsDirectory)
         self.profileListboxSetting.listSetting.setValueToFolders()
     lastSelectionIndex = min(
         lastSelectionIndex,
         len(self.profileListboxSetting.listSetting.value) - 1)
     self.profileListboxSetting.value = self.profileListboxSetting.listSetting.value[
         lastSelectionIndex]
     self.profileListboxSetting.setStateToValue()
     self.no()