Commit 3b6e708d authored by sumpfralle's avatar sumpfralle

added an estimation of the remaining processing time to the progress bar


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@687 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent b16e66ea
...@@ -2515,6 +2515,7 @@ class ProjectGui: ...@@ -2515,6 +2515,7 @@ class ProjectGui:
self.update_progress_bar("", 0) self.update_progress_bar("", 0)
self.progress_cancel_button.set_sensitive(True) self.progress_cancel_button.set_sensitive(True)
self.progress_widget.show() self.progress_widget.show()
self._progress_start_time = time.time()
else: else:
self.progress_widget.hide() self.progress_widget.hide()
self.task_pane.set_sensitive(True) self.task_pane.set_sensitive(True)
...@@ -2530,8 +2531,28 @@ class ProjectGui: ...@@ -2530,8 +2531,28 @@ class ProjectGui:
if not percent is None: if not percent is None:
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
if self.progress_bar.get_fraction() > 0:
eta_full = (time.time() - self._progress_start_time) / self.progress_bar.get_fraction()
if eta_full > 0:
eta_delta = eta_full - (time.time() - self._progress_start_time)
eta_delta = int(round(eta_delta))
eta_delta_obj = datetime.timedelta(seconds=eta_delta)
eta_text = "%s remaining ..." % str(eta_delta_obj)
else:
eta_text = None
else:
eta_text = None
lines = []
if not text is None: if not text is None:
self.progress_bar.set_text(text) lines.append(text)
else:
old_lines = self.progress_bar.get_text().split(os.linesep)
# skip the last line
lines.extend(old_lines[:-1])
if eta_text:
lines.append(eta_text)
self.progress_bar.set_text(os.linesep.join(lines))
# update the GUI # update the GUI
while gtk.events_pending(): while gtk.events_pending():
gtk.main_iteration() gtk.main_iteration()
......
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