def _load_presets(model, file_path): try: tree = et.parse(file_path) except: return root = tree.getroot() for node in root: name = node.get('name') (hours, minutes, seconds) = seconds_to_hms(int(node.get('duration'))) command = node.get('command') next_timer = node.get('next_timer') auto_start = node.get('auto_start') model.append((name, hours, minutes, seconds, command, next_timer, deserialize_bool(auto_start)))
def _on_timer_time_changed(self, timer): hours, minutes, seconds = utils.seconds_to_hms(timer.get_remaining_time()) print 'Remaining time: %d, %d, %d' % (hours, minutes, seconds) name = self.timer.get_name() self.status_button.set_label(utils.construct_time_str(self.timer.get_remaining_time(), show_all=False)) fraction_remaining = float(self.timer.get_remaining_time()) / self.timer.get_duration() progress = min(1.0, max(0.0, 1.0 - fraction_remaining)) self.status_button.set_progress(progress) if len(name) > 0: # HH:MM:SS (<timer name>) self.status_button.set_tooltip(_('%02d:%02d:%02d (%s)') % (hours, minutes, seconds, name)) else: # HH:MM:SS self.status_button.set_tooltip(_('%02d:%02d:%02d') % (hours, minutes, seconds))
def _on_timer_time_changed(self, timer): hours, minutes, seconds = utils.seconds_to_hms( timer.get_remaining_time()) print 'Remaining time: %d, %d, %d' % (hours, minutes, seconds) name = self._timer.get_name() self._status_button.set_label( utils.construct_time_str(self._timer.get_remaining_time(), show_all=False)) fraction_remaining = float( self._timer.get_remaining_time()) / self._timer.get_duration() progress = min(1.0, max(0.0, 1.0 - fraction_remaining)) self._status_button.set_progress(progress) if len(name) > 0: # HH:MM:SS (<timer name>) self._status_button.set_tooltip( _('%02d:%02d:%02d (%s)') % (hours, minutes, seconds, name)) else: # HH:MM:SS self._status_button.set_tooltip( _('%02d:%02d:%02d') % (hours, minutes, seconds))