def saveAndLoad(self, tasks, categories=None): categories = categories or [] self.emptyTaskFile.tasks().extend(tasks) self.emptyTaskFile.categories().extend(categories) self.emptyTaskFile.save() self.emptyTaskFile.load() self.assertEqual([task.subject() for task in tasks], [task.subject() for task in self.emptyTaskFile.tasks()]) self.assertEqual([category.subject() for category in categories], [category.subject() for category in self.emptyTaskFile.categories()])
def __init__(self, parent, task, *args, **kwargs): super(SubjectPage, self).__init__(parent, task, *args, **kwargs) descriptionBox = widgets.BoxWithFlexGridSizer(self, _('Description'), cols=2, growableRow=1, growableCol=1) descriptionBox.add(_('Subject')) self._subjectEntry = widgets.SingleLineTextCtrl(descriptionBox, task.subject()) descriptionBox.add(self._subjectEntry, proportion=1, flag=wx.EXPAND) descriptionBox.add(_('Description')) self._descriptionEntry = widgets.MultiLineTextCtrl(descriptionBox, task.description()) descriptionBox.add(self._descriptionEntry, proportion=1, flag=wx.EXPAND) priorityBox = widgets.BoxWithFlexGridSizer(self, _('Priority'), cols=2) priorityBox.add(_('Priority')) self._prioritySpinner = wx.SpinCtrl(priorityBox, value=render.priority(task.priority()), style=wx.SP_ARROW_KEYS) # Can't use sys.maxint because Python and wxPython disagree on what the # maximum integer is on Suse 10.0 x86_64. Using sys.maxint will cause # an Overflow exception, so we use a constant: maxint = 2147483647 self._prioritySpinner.SetRange(-maxint, maxint) priorityBox.add(self._prioritySpinner) for box, proportion in [(descriptionBox, 1), (priorityBox, 0)]: box.fit() self.add(box, proportion=proportion, flag=wx.EXPAND|wx.ALL, border=5) self.fit()
def assertItems(self, *tasks): self.viewer.widget.expandAllItems() self.assertEqual(self.viewer.size(), len(tasks)) for index, task in enumerate(tasks): if type(task) == type((),): task, nrChildren = task else: nrChildren = 0 subject = task.subject() treeItem = self.viewer.widget.GetItemChildren(recursively=True)[index] self.assertEqual(subject, self.viewer.widget.GetItemText(treeItem)) self.assertEqual(nrChildren, self.viewer.widget.GetChildrenCount(treeItem, recursively=False))
def addPage(self, task): page = TaskEditBook(self._interior, task, self._taskList, self._uiCommands, self._settings, self._categories) self._interior.AddPage(page, task.subject())
def addTaskRecursively(task, parentItem=None): item = self._taskEntry.Append(task.subject(), parent=parentItem, clientData=task) for child in task.children(): addTaskRecursively(child, item)
def getItemText(self, index): task = self.getItemWithIndex(index) return task.subject()