def __init__(self, parent, _task, row_id): """ :param TrackerDisplay parent: Tkinter Frame within which this frame resides. :param task.Task _task: Datastore that this class will draw. :return: """ logging.debug("Creating display for task %s" % _task) self.task = _task if self.task.archived: logging.debug("Aborting display for task %s as it is archived." % _task) return self.parent = parent self.row_id = row_id Tkinter.Frame.__init__(self, self.parent, borderwidth=2, relief=Tkinter.GROOVE) # Create a button which can be clicked to change the task name self.task_name = Tkinter.Button(self, text=self.task.task_name, command=prompt_for_value(self, self.set_name, "Enter new task name")) # Create a button that prompts for a name, then creates a new subtask. self.add_new_subtask_button = Tkinter.Button(self, text="+Subtask", command=prompt_for_value(self.parent, self.add_subtask, "Enter subtask name")) # Create a button that archives this task when pressed. self.archive_task_button = Tkinter.Button(self, text="Hide", command=self.archive_self) # Create the headers for the total, estimate and remaining columns self.spent_header = Tkinter.Label(self, text="Spent") self.estimate_header = Tkinter.Label(self, text="Estimate") self.remaining_header = Tkinter.Label(self, text="Gain") # Create the labels/entries for the total, estimate and remaining for the entire task. total_spent = self.task.get_total_time_spent() self.spent_value = Tkinter.Label(self, text=str(total_spent)) self.estimate_entry = Tkinter.Label(self, text=str(self.task.estimate)) self.remaining_value = Tkinter.Label(self, text=str(self.task.estimate - total_spent)) # Create a label for each subtask. self.subtask_displays = [] for subtask in self.task.subtasks: self.add_subtask_display(subtask) # Create a set of entries (a week display) for each week this task exists for self.week_displays = [] for _week in self.task.weeks: self.add_week(_week) self.draw()
def __init__(self, parent_task_display, subtask): """ :param TaskDisplay parent_task_display: Task display object that owns this subtask :param subtask.Subtask subtask: subtask object :return: """ self.parent = parent_task_display self.subtask = subtask # Create a button whose action is to rename the subtask Tkinter.Button.__init__(self, parent_task_display, text=self.subtask.name, command=prompt_for_value(self, self.set_name, "Enter new subtask name"))
def __init__(self, parent, _tracker): """ :param Tkinter.Tk parent: Tkinter root. """ self.tracker = _tracker self.parent = parent Tkinter.Frame.__init__(self, self.parent) # Create a frame that will house all of the buttons so that they fit nicely into one grid slot. self.button_frame = Tkinter.Frame(self) self.add_task_button = Tkinter.Button(self.button_frame, text="+Task", command=prompt_for_value(self, self.add_task, "Enter task name")) self.add_week_button = Tkinter.Button(self.button_frame, text="+Week", command=self.add_week) self.increment_week_archive_button = Tkinter.Button(self.button_frame, text=">", command=self.increment_week_archive) self.decrement_week_archive_button = Tkinter.Button(self.button_frame, text="<", command=self.decrement_week_archive) self.archive_button = Tkinter.Button(self.button_frame, text="Archive", command=self.show_archive) self.save_button = Tkinter.Button(self.button_frame, text="Save", command=self._save) self.load_button = Tkinter.Button(self.button_frame, text="Load", command=self._load) self.archive_display = None self.parent.bind('<Return>', self.update) self.task_displays = {} self.week_labels = [] for task_name in self.tracker.task_order: self.add_task_display(task_name) for week_index in range(self.tracker.week_index): self.add_week_label(self.tracker.get_week_name(week_index), week_index) for week_index, week_label in enumerate(self.week_labels): counter = 0 for _task_display in self.task_displays.itervalues(): counter += _task_display.task.get_time_for_week(week_index) week_label.update_to_value(counter) self.draw()