Example #1
0
 def decrementTimer(self):
     state = PomodoroState()
     state.minutes -= 1
     if state.minutes <= 0:
         state.inwork = False
         self.toggleState(False)
         self.updateUI()
     state.text = self.time_str()
Example #2
0
 def decrementTimer(self):
     state = PomodoroState()
     state.minutes -= 1
     if state.minutes <= 0:
         state.inwork = False
         self.toggleState(False)
         self.updateUI()
     state.text = self.time_str()
Example #3
0
    def onPomodoroEnd(self):
        """Calls when pomodoro finished"""
        opts = PomodoroOptions()
        state = PomodoroState()

        state.inc_times()

        # общее количество выполненых помидор
        opts['last'] = int(opts.getitem_def('last', 0)) + 1

        # за текущий день
        dt = state.TodayStr()
        opts[dt] = int(opts.getitem_def(dt, 0)) + 1

        desc = self.askPomodoroDescription()
        DataBaseController().newPomodoro(desc)
Example #4
0
    def onPomodoroEnd(self):
        """Calls when pomodoro finished"""
        opts = PomodoroOptions()
        state = PomodoroState()

        state.inc_times()

        # общее количество выполненых помидор
        opts['last'] = int(opts.getitem_def('last', 0)) + 1

        # за текущий день
        dt = state.TodayStr()
        opts[dt] = int(opts.getitem_def(dt, 0)) + 1

        desc = self.askPomodoroDescription()
        DataBaseController().newPomodoro(desc)
Example #5
0
 def updateUI(self):
     #TODO: проверять видимо ли окно. иначе не обновлять
     #TODO: remove this ugly method
     state = PomodoroState()
     self.timer_ctrl.SetValue(state.text)
     self.start_button.SetLabel(self.__state_dict[state.active]['bs'])
     self.txt.SetLabel(state.caption)
     self.times_l.SetLabel(u"%d помидор" % state.GetTodayCount())
Example #6
0
    def toggleState(self, user=True, active=None):
        state = PomodoroState()

        info = self._state_info[(state.active if active == None else active)]

        if state.inwork and user:
            state.active = info['next_early']
        else:
            state.active = info['next']
        info = self._state_info[state.active]
        state.inwork = info['dec']
        if info.has_key('max_min'):
            state.max_minutes = info['max_min']
        else:
            state.max_minutes = info['max_min_s'](state.times)
        if info.has_key('exec'):
            info['exec']()

        state.percent = 1.0
        state.text = (info['text']
                      if info['text'] != None else self.time_str())
        state.caption = info['caption']
        self.initTimers(info)
        self.updateUI()
Example #7
0
    def toggleState(self, user=True, active=None):
        state = PomodoroState()

        info = self._state_info[(state.active if active == None else active)]

        if state.inwork and user:
            state.active = info['next_early']
        else:
            state.active = info['next']
        info = self._state_info[state.active]
        state.inwork = info['dec']
        if info.has_key('max_min'):
            state.max_minutes = info['max_min']
        else:
            state.max_minutes = info['max_min_s'](state.times)
        if info.has_key('exec'):
            info['exec']()

        state.percent = 1.0
        state.text = (info['text'] if info['text'] != None else self.time_str())
        state.caption = info['caption']
        self.initTimers(info)
        self.updateUI()
Example #8
0
 def __init__(self):
     wx.Frame.__init__(
         self,
         None,
         -1,
         'Pomodoro it!',
         style=wx.BORDER_DEFAULT | wx.STAY_ON_TOP,
         size=(220, 120),
     )
     state = PomodoroState()
     self.__state_dict = {
         state.StateNoState: {
             'bs': '...'
         },
         state.StateInPomodoro: {
             'bs': u"Отменить..."
         },
         state.StateInRest: {
             'bs': u"Отдыхайте!"
         },
         state.StateWaitingPomodoro: {
             'bs': u"Начать помидору"
         },
         state.StateWaitingRest: {
             'bs': u"Начать отдых"
         },
         state.StatePomodoroKilled: {
             'bs': u"Начать помидору"
         },
     }
     self.buildFrame()
     self.updateUI()
     self.makeMenu()
     self.Show(False)
     NotificationCenter().addObserver(self, self.onDBUpdate, "dbUpdated")
     NotificationCenter().addObserver(self, self.onUpdateUI, "updateUI")
Example #9
0
    def initProcess(self):
        self.now_creation = True

        self.t1 = Timer(1000, self.updateTimer)
        self.t2 = Timer(60000, self.decrementTimer)
        if PomodoroState.debug:
            self.t1.set_delay(1000)
            self.t2.set_delay(1000)
        self.time_str = lambda: str(PomodoroState().minutes) + ' min'
        self._state_info = {
            PomodoroState.StateNoState: {
                'next': PomodoroState.StateWaitingPomodoro,
                'next_early': PomodoroState.StateWaitingPomodoro,
                'upd': False,
                'dec': False,
                'max_min': 0,
                'text': '...',
                'caption': 'Pomodoro!',
            },
            PomodoroState.StatePomodoroKilled: {
                'next': PomodoroState.StateInPomodoro,
                'next_early': PomodoroState.StateInPomodoro,
                'upd': False,
                'dec': False,
                'max_min': 0,
                'text': u"Помидора сброшена",
                'caption': 'Pomodoro!',
            },
            PomodoroState.StateInPomodoro: {
                'next': PomodoroState.StateWaitingRest,
                'next_early': PomodoroState.StatePomodoroKilled,
                'upd': True,
                'dec': True,
                'max_min': 25,
                'text': None,
                'caption': 'Pomodoro!',
            },
            PomodoroState.StateInRest: {
                'next': PomodoroState.StateWaitingPomodoro,
                'next_early': PomodoroState.StateInPomodoro,
                'upd': True,
                'dec': True,
                'max_min_s': lambda times: (20 if times % 4 == 0 else 5),
                'cycle': 4,
                'text': None,
                'caption': 'Pomodoro!',
            },
            PomodoroState.StateWaitingPomodoro: {
                'next': PomodoroState.StateInPomodoro,
                'next_early': PomodoroState.StateInPomodoro,
                'upd': False,
                'dec': False,
                'max_min': 0,
                'text': u"Ожидание начала работы...",
                'caption': 'Pomodoro!',
            },
            PomodoroState.StateWaitingRest: {
                'next': PomodoroState.StateInRest,
                'next_early': PomodoroState.StateInRest,
                'upd': False,
                'dec': False,
                'max_min': 0,
                'text': u"Ожидание отдыха...",
                'exec': self.onPomodoroEnd,
                'caption': 'Pomodoro!',
            },
        }

        self.initialState()
        self.updateUI()
        self.now_creation = False
        self.initialState()