Commit f7e9ad9c authored by sumpfralle's avatar sumpfralle

fixed the removal of previous "time estimation" lines in the progress control...

fixed the removal of previous "time estimation" lines in the progress control text by using a proper string comparision (instead of simply removing the last line of the previous text)


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@709 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 09b589cc
...@@ -46,6 +46,7 @@ import time ...@@ -46,6 +46,7 @@ import time
import logging import logging
import datetime import datetime
import traceback import traceback
import re
import os import os
import sys import sys
...@@ -2575,6 +2576,7 @@ class ProjectGui: ...@@ -2575,6 +2576,7 @@ class ProjectGui:
percent = min(max(percent, 0.0), 100.0) percent = min(max(percent, 0.0), 100.0)
self.progress_bar.set_fraction(percent/100.0) self.progress_bar.set_fraction(percent/100.0)
# "estimated time of arrival" text # "estimated time of arrival" text
time_estimation_suffix = " remaining ..."
if self.progress_bar.get_fraction() > 0: if self.progress_bar.get_fraction() > 0:
eta_full = (time.time() - self._progress_start_time) / self.progress_bar.get_fraction() eta_full = (time.time() - self._progress_start_time) / self.progress_bar.get_fraction()
if eta_full > 0: if eta_full > 0:
...@@ -2589,18 +2591,18 @@ class ProjectGui: ...@@ -2589,18 +2591,18 @@ class ProjectGui:
eta_delta = self._last_eta_delta eta_delta = self._last_eta_delta
self._last_eta_delta = eta_delta self._last_eta_delta = eta_delta
eta_delta_obj = datetime.timedelta(seconds=eta_delta) eta_delta_obj = datetime.timedelta(seconds=eta_delta)
eta_text = "%s remaining ..." % str(eta_delta_obj) eta_text = "%s%s" % (eta_delta_obj, time_estimation_suffix)
else: else:
eta_text = None eta_text = None
else: else:
eta_text = None eta_text = None
lines = []
if not text is None: if not text is None:
lines.append(text) lines = [text]
else: else:
old_lines = self.progress_bar.get_text().split(os.linesep) old_lines = self.progress_bar.get_text().split(os.linesep)
# skip the last line # skip the time estimation line
lines.extend(old_lines[:-1]) lines = [line for line in old_lines
if not line.endswith(time_estimation_suffix)]
if eta_text: if eta_text:
lines.append(eta_text) lines.append(eta_text)
self.progress_bar.set_text(os.linesep.join(lines)) self.progress_bar.set_text(os.linesep.join(lines))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment