def run(self): X = globals.X Y = globals.Y frame = Frame() frame.set_focus(True) frame.set_size(X+1,Y) frame.set_position(0,0) frame.create() def update_patch(target): for y in range(Y): frame.addstr(0,y,' '*X,curses.A_REVERSE) frame.update = types.MethodType(update_patch,frame) timer = self.windows["Timer"].frames["timer_frame"] for i in range(3): frame.update() frame.refresh() time.sleep(0.2) self.screen.erase() self.screen.refresh() window = self.get_window() timer.update() window.update() window.refresh() self.banner.update() self.banner.refresh() time.sleep(0.2) del frame
def push_switcher(self): frame = Frame() frame.name = "taskswitcher_element" frame.task_list = [] frame.current_task = -1 frame.enabled = True frame.selected = False def update_patch(target): target.erase() color = config.COLOR_FOCUS if target.enabled and target.current_task > -1: if target.selected: target.addstr(0,0,"\u25C0", curses.color_pair(color)) else: target.addstr(0,0,"\u25C0") else: if target.enabled and target.selected: target.addstr(0,0,"\u25C1", curses.color_pair(color)) else: target.addstr(0,0,"\u25C1") if target.enabled and target.current_task+1 < len(target.task_list): if target.selected: target.addstr(target.size[0]-3,0,"\u25B6", curses.color_pair(color)) else: target.addstr(target.size[0]-3,0,"\u25B6") else: if target.enabled and target.selected: target.addstr(target.size[0]-3,0,"\u25B7", curses.color_pair(color)) else: target.addstr(target.size[0]-3,0,"\u25B7") if target.current_task >= 0: desc = globals.database.tasks[target.get_task()].desc target.addstr(3,0,desc) def get_task_patch(target): if target.current_task >= 0: return target.task_list[target.current_task] else: return None def next_patch(target): if target.enabled and target.current_task+1 < len(target.task_list): target.current_task += 1 def prev_patch(target): if target.enabled and target.current_task-1 >= -1: target.current_task -= 1 def task_list_patch(target,tasks): target.task_list = tasks frame.update = types.MethodType(update_patch,frame) frame.next_task = types.MethodType(next_patch,frame) frame.prev_task = types.MethodType(prev_patch,frame) frame.set_task_list = types.MethodType(task_list_patch,frame) frame.get_task = types.MethodType(get_task_patch,frame) idx = len(self.stack) try: frame.set_position(self.position[0],self.position[1]+idx) frame.set_size(self.size[0],self.size[1]) frame.create() except: pass frame.focus = True frame.set_task_list(globals.database.task_list[self.get_task()]) #if self.get_task() != None: # frame.set_task_list(globals.database.task_list[self.get_task()]) #else: # frame.set_task_list([]) self.add_frame(str(idx),frame) self.stack.append(frame) if self.current_switcher == -1: self.current_switcher = 0 self.stack[0].selected = True
def init(self): x,y = self.position # tasks window = Window() window.name = "tasks" frame = Frame() frame.name = "tasks_frame" frame.set_size(10,1) frame.set_position(x,y) def update_patch(target): target.erase() options = None if target.selected: options = curses.A_BOLD if target.selected_title: options = options | curses.color_pair(config.COLOR_FOCUS) target.addstr(0,0,"Tasks",options) frame.update = types.MethodType(update_patch,frame) window.add_frame(frame.name,frame) frame = Taskeditor() frame.name = "taskeditor_frame" frame.set_position(x,y+2) window.add_frame(frame.name,frame) window.input_frame = frame self.stack.append(window) self.add_frame(window.name,window) # pomodoro time window = Window() window.name = "pomodoro_time" x,y = self.position frame = Frame() frame.name = "pomodoro_time_frame" frame.set_size(10,1) frame.set_position(40,y) def update_patch(target): target.erase() options = None if target.selected: options = curses.A_BOLD if target.selected_title: options = options | curses.color_pair(config.COLOR_FOCUS) target.addstr(0,0,"Pomodoro",options) frame.update = types.MethodType(update_patch,frame) window.add_frame("pomodoro_time_frame",frame) frame = Input() frame.name = "pomodoro_time_edit_frame" frame.init("time") frame.variable = "TIME_POMODORO" frame.value = config.TIME_POMODORO frame.set_position(40+14,y) window.add_frame("pomodoro_time_edit_frame",frame) window.input_frame = frame self.stack.append(window) self.add_frame(window.name,window) # break time window = Window() window.name = "break_time" frame = Frame() frame.name = "break_time_frame" frame.set_size(10,1) frame.set_position(40,y+1) def update_patch(target): target.erase() options = None if target.selected: options = curses.A_BOLD if target.selected_title: options = options | curses.color_pair(config.COLOR_FOCUS) target.addstr(0,0,"Break",options) frame.update = types.MethodType(update_patch,frame) window.add_frame("break_time_frame",frame) frame = Input() frame.name = "break_time_edit_frame" frame.init("time") frame.variable = "TIME_BREAK" frame.value = config.TIME_BREAK frame.set_position(40+14,y+1) window.add_frame("break_time_edit_frame",frame) window.input_frame = frame self.stack.append(window) self.add_frame(window.name,window) # slots window = Window() window.name = "slot_time" frame = Frame() frame.name = "slot_frame" frame.variable = "TIME_SLOT" frame.set_size(10,1) frame.set_position(40,y+2) def update_patch(target): target.erase() options = None if target.selected: options = curses.A_BOLD if target.selected_title: options = options | curses.color_pair(config.COLOR_FOCUS) target.addstr(0,0,"Slots",options) frame.update = types.MethodType(update_patch,frame) window.add_frame("slot_frame",frame) frame = Sloteditor() frame.name = "slot_edit_frame" frame.set_position(40+3,y+4) window.add_frame(frame.name,frame) window.input_frame = frame self.stack.append(window) self.add_frame(window.name,window) # initial state for w in self.stack: w.set_variable("selected",False) w.set_variable("selected_title",False) self.select(0) self.set_variable("selected_input",False)