MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / ComputeProgressStats

Method ComputeProgressStats

PySimpleGUI/PySimpleGUI.py:18152–18178  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

18150 return METER_OK
18151
18152 def ComputeProgressStats(self):
18153 utc = datetime.datetime.utcnow()
18154 time_delta = utc - self.start_time
18155 total_seconds = time_delta.total_seconds()
18156 if not total_seconds:
18157 total_seconds = 1
18158 try:
18159 time_per_item = total_seconds / self.current_value
18160 except:
18161 time_per_item = 1
18162 seconds_remaining = (self.max_value - self.current_value) * time_per_item
18163 time_remaining = str(datetime.timedelta(seconds=seconds_remaining))
18164 time_remaining_short = (time_remaining).split(".")[0]
18165 time_delta_short = str(time_delta).split(".")[0]
18166 total_time = time_delta + datetime.timedelta(seconds=seconds_remaining)
18167 total_time_short = str(total_time).split(".")[0]
18168 self.stat_messages = [
18169 '{} of {}'.format(self.current_value, self.max_value),
18170 '{} %'.format(100 * self.current_value // self.max_value),
18171 '',
18172 ' {:6.2f} Iterations per Second'.format(self.current_value / total_seconds),
18173 ' {:6.2f} Seconds per Iteration'.format(total_seconds / (self.current_value if self.current_value else 1)),
18174 '',
18175 '{} Elapsed Time'.format(time_delta_short),
18176 '{} Time Remaining'.format(time_remaining_short),
18177 '{} Estimated Total Time'.format(total_time_short)]
18178 return self.stat_messages
18179
18180
18181def one_line_progress_meter(title, current_value, max_value, *args, key='OK for 1 meter', orientation='v', bar_color=(None, None), button_color=None,

Callers 1

UpdateMeterMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected