當前位置: 首頁>>代碼示例>>Python>>正文


Python MainWindow.update_pomodoro_count方法代碼示例

本文整理匯總了Python中main_window.MainWindow.update_pomodoro_count方法的典型用法代碼示例。如果您正苦於以下問題:Python MainWindow.update_pomodoro_count方法的具體用法?Python MainWindow.update_pomodoro_count怎麽用?Python MainWindow.update_pomodoro_count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在main_window.MainWindow的用法示例。


在下文中一共展示了MainWindow.update_pomodoro_count方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: DomorIndicator

# 需要導入模塊: from main_window import MainWindow [as 別名]
# 或者: from main_window.MainWindow import update_pomodoro_count [as 別名]

#.........這裏部分代碼省略.........
            self.reset()

    def _update_item(self, item_id, img_path, label=None):
        """
        Update image for button
        :param button_id: id of button which is updated
        :param img_path: path to image
        :return: None
        """
        try:
            item = self.builder.get_object(item_id)
            img = Gtk.Image.new_from_file(img_path)
            item.set_image(img)
            if label:
                item.set_label(label)
        except Exception as e:
            print item_id
            print e.message

    def _update_time(self):
        """
        Update display time on UI
        :return:
        """
        time_string = "%02d:%02d" % (self.time / 60, self.time % 60)
        self.lb_clock.set_label(time_string)

        if self.state == State.BREAK:
            self.break_screen.update_time(time_string)

        if self.main_window:
            self.main_window.update_time(time_string)

    def _update_pomodoro_count(self):
        label = str(self.count) + \
            (" pomodoro" if self.count <= 1 else " pomodoros")
        self.lb_counter.set_label(label)

        if self.main_window:
            self.main_window.update_pomodoro_count(self.count)

    def count_down(self):
        if self.state != State.IDLE:

            if self.state == State.WORK:
                if self.time == 0:
                    self.count += 1

                    # long_work_time is the number of short working session
                    # between long break
                    if self.count % self.settings.long_work_time == 0:
                        self.start_break_period(self.settings.long_break_time)
                    else:
                        self.start_break_period(self.settings.short_break_time)
                    self._update_pomodoro_count()
                else:
                    self.time -= 1
                    self.work_time += 1

            else:
                if self.state == State.BREAK and self.time == 0:
                    # end of break period star new short work period
                    self.start_work_period()
                else:
                    self.time -= 1
            self._update_time()
開發者ID:bluzky,項目名稱:domor-gtk,代碼行數:70,代碼來源:domor_indicator.py


注:本文中的main_window.MainWindow.update_pomodoro_count方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。