def handle_input(self): mb = globals.messageboard window = self.stack[self.current_select] window.set_variable("selected_title",False) window.set_variable("selected_input",True) window.update() window.refresh() if window.name == "pomodoro_time": value = window.input_frame.value window.input_frame.handle_input() nvalue = window.input_frame.value if value != nvalue: config.TIME_BREAK = nvalue globals.database.update_config("TIME_POMODORO",nvalue) config.init() elif window.name == "break_time": value = window.input_frame.value window.input_frame.handle_input() nvalue = window.input_frame.value if value != nvalue: config.TIME_BREAK = nvalue globals.database.update_config("TIME_BREAK",nvalue) config.init() else: window.input_frame.handle_input() window.set_variable("selected_title",True) window.set_variable("selected_input",False) window.update() window.refresh()
def load_config(self): configlist = self.request("SELECT variable,value FROM config") if configlist != None: for variable,value in configlist: try: exec("config."+str(variable)+" = "+str(value)) except: exec("config."+str(variable)+" = '"+str(value)+"'") else: log.debug("No config loaded from database") config.init()
def sync(self): if self.modified: self.modified = False self.slots self.titles globals.database.update_config("TIME_SLOT",self.slots) globals.database.update_config("TIME_SLOT_NAME",self.titles) globals.database.load_config() config.init() weekview = globals.interface.windows["Weekview"].frames["weekview_frame"] weekview.reload() weekview.update()
def __init__(self, stdscr): self.screen = stdscr globals.Y,globals.X = self.screen.getmaxyx() X,Y = globals.X,globals.Y globals.interface = self globals.database.load_config() config.init() globals.messageboard = Messageboard() mb = globals.messageboard mb.create() self.width = 81 self.size = [ X, Y ] if self.size[0] < 81: self.size[0] = 81 self.switch_window = None self.windows = { "Timer":Window(),"Weekview":Window(),"Settings":Window() } self.window_list = [ "Timer", "Weekview", "Settings" ] # create banner self.banner = Banner() self.banner.name = "Banner" self.banner.create() self.banner.set_focus(True) self.banner.set_window_list(self.window_list) # build setting window window = self.windows["Settings"] window.name = "Settings" frame = Configeditor() frame.name = "config_frame" frame.set_position(4,4) frame.init() window.add_frame(frame.name,frame) mb.message("[ENTER]: Edit",window.name) window.add_frame(mb.name,mb) window.create() self.patch_settings(window) # build weekview window window = self.windows["Weekview"] window.name = "Weekview" frame = Weekswitcher() frame.name = "weekswitcher_frame" frame.set_position(32,4) window.add_frame(frame.name,frame) frame = Weekview() frame.name = "weekview_frame" frame.set_size(80,9) frame.set_position(4,10) frame.reload() window.add_frame(frame.name,frame) frame = Weeklegend() frame.name = "weeklegend_frame" frame.set_size(80,10) frame.set_position(6,21) window.add_frame(frame.name,frame) frame = Taskswitcher() frame.name = "taskswitcher_frame" frame.set_position(5,21) frame.set_manual_focus(False) frame.disable() window.add_frame(frame.name,frame) mb.message("[ENTER]: Edit",window.name) window.add_frame(mb.name,mb) window.create() self.patch_weekview(window) # build Timer window window = self.windows["Timer"] window.name = "Timer" frame = Taskswitcher() frame.name = "taskswitcher_frame" x = int((self.width - frame.size[0]) / 2) frame.set_position(x,14) window.add_frame(frame.name,frame) frame = Overtime() frame.name = "overtime_frame" frame.set_position(x,6+5) window.add_frame(frame.name,frame) frame = Timer() frame.name = "timer_frame" frame.set_position(x,6) window.add_frame(frame.name,frame) frame = Frame() frame.name = "color_frame" frame.set_size(36,1) frame.set_position(x,4) def update_patch(target): taskswitcher = globals.interface.windows["Timer"].frames["taskswitcher_frame"] target.erase() width = 14 start = int((target.size[0] - width) / 2)-1 target.addstr(start,0,"\u25D6") target.addstr(start+width-1,0,"\u25D7") target.addstr(start+1,0,"\u25A0"*(width-2),curses.color_pair(taskswitcher.get_color())) frame.update = types.MethodType(update_patch,frame) window.add_frame(frame.name,frame) mb.message("[SPACE]: Start, [ENTER]: Edit, [b]: Break",window.name) window.add_frame(mb.name,mb) frame = Clock() frame.name = "clock_frame" frame.set_position(x+29,11) window.add_frame(frame.name,frame) window.create() clockthread = threading.Thread(target=frame.run,name="Clock") clockthread.setDaemon(True) clockthread.start() self.patch_timer(window)