All pastes #294765 Raw Edit

Unnamed

public text v1 · immutable
#294765 ·published 2006-12-28 20:18 UTC
rendered paste body
# NOTE: self.projectsList is my TreeView
#       self.projects is the ListStore which is linked to self.projectsList

	def removeProject(self):
		selected = self.projectsList.get_selection()
		selectedModel, selectedIter = selected.get_selected()
		if selectedIter:
			path = selectedModel.get_path(selectedIter)
			selectedModel.remove(selectedIter)
			selected.select_path(path)
			if not selected.path_is_selected(path):
				row = path[0]-1
				if row >= 0:
					selected.select_path(row)

	def saveProjects(self):
		db = shelve.open(DB_FILE)
		projectsIter = self.projects.get_iter_root()
		while projectsIter:
			currentProject = self.projects.get_value(projectsIter, 6)
			print currentProject.active
			db[self.projects.get_string_from_iter(projectsIter)] = currentProject
			projectsIter = self.projects.iter_next(projectsIter)
		db.close()