You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
5.6 KiB

2 years ago
Elapsed / Remaining Time on Progress Bar parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Jack McKew <jackmckew2@gmail.com> 1594344614 +1000 committer Jack McKew <jackmckew2@gmail.com> 1594346638 +1000 Elapsed / Remaining Time on Progress Bar parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246420 +1000 parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246359 +1000 Elapsed / Remaining Time on Progress Bar Elapsed / Remaining Time on Progress Bar Time Remaining Text for Progress Time remaining somewhat working Time format working Add tests and pythn 2.7 compat Incase python 2 import perf counter in func Fix flickering text and align Remove transactUI Add new decorators Update time remaining notes in README Amend tests with new arguments Remove unused import Separate into time module Move to dictionary structure options Explicitly show time text Amend tests for separate module Integration test - missing on complete tests Remove old code Elapsed / Remaining Time on Progress Bar parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246420 +1000 parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246359 +1000 Elapsed / Remaining Time on Progress Bar Elapsed / Remaining Time on Progress Bar Time Remaining Text for Progress Time remaining somewhat working Time format working Add tests and pythn 2.7 compat Incase python 2 import perf counter in func Fix flickering text and align Remove transactUI Add new decorators Update time remaining notes in README Amend tests with new arguments Remove unused import Separate into time module Move to dictionary structure options Explicitly show time text Amend tests for separate module Remove old code Pass testdata as dict instead of kwargs Merge dictionaries for defaults Test almost working Delete settings.json Revert "Test almost working" This reverts commit f17d50681cae664719f67a7e8cc0b1feaf1ac4c7. Back to working state Remove unhelpful test Update docs Working without updated test Add tests for time remaining text Elapsed / Remaining Time on Progress Bar parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Jack McKew <jackmckew2@gmail.com> 1594344614 +1000 committer Jack McKew <jackmckew2@gmail.com> 1594346638 +1000 Elapsed / Remaining Time on Progress Bar parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246420 +1000 parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246359 +1000 Elapsed / Remaining Time on Progress Bar Elapsed / Remaining Time on Progress Bar Time Remaining Text for Progress Time remaining somewhat working Time format working Add tests and pythn 2.7 compat Incase python 2 import perf counter in func Fix flickering text and align Remove transactUI Add new decorators Update time remaining notes in README Amend tests with new arguments Remove unused import Separate into time module Move to dictionary structure options Explicitly show time text Amend tests for separate module Integration test - missing on complete tests Remove old code Elapsed / Remaining Time on Progress Bar parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246420 +1000 parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246359 +1000 Elapsed / Remaining Time on Progress Bar Elapsed / Remaining Time on Progress Bar Time Remaining Text for Progress Time remaining somewhat working Time format working Add tests and pythn 2.7 compat Incase python 2 import perf counter in func Fix flickering text and align Remove transactUI Add new decorators Update time remaining notes in README Amend tests with new arguments Remove unused import Separate into time module Move to dictionary structure options Explicitly show time text Amend tests for separate module Remove old code Pass testdata as dict instead of kwargs Merge dictionaries for defaults Test almost working Delete settings.json Revert "Test almost working" This reverts commit f17d50681cae664719f67a7e8cc0b1feaf1ac4c7. Back to working state Remove unhelpful test Update docs Working without updated test Add tests for time remaining text Remove artifact from squashing Amend artifacts Handle no progress and tidy up footer label
4 years ago
Elapsed / Remaining Time on Progress Bar parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Jack McKew <jackmckew2@gmail.com> 1594344614 +1000 committer Jack McKew <jackmckew2@gmail.com> 1594346638 +1000 Elapsed / Remaining Time on Progress Bar parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246420 +1000 parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246359 +1000 Elapsed / Remaining Time on Progress Bar Elapsed / Remaining Time on Progress Bar Time Remaining Text for Progress Time remaining somewhat working Time format working Add tests and pythn 2.7 compat Incase python 2 import perf counter in func Fix flickering text and align Remove transactUI Add new decorators Update time remaining notes in README Amend tests with new arguments Remove unused import Separate into time module Move to dictionary structure options Explicitly show time text Amend tests for separate module Integration test - missing on complete tests Remove old code Elapsed / Remaining Time on Progress Bar parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246420 +1000 parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246359 +1000 Elapsed / Remaining Time on Progress Bar Elapsed / Remaining Time on Progress Bar Time Remaining Text for Progress Time remaining somewhat working Time format working Add tests and pythn 2.7 compat Incase python 2 import perf counter in func Fix flickering text and align Remove transactUI Add new decorators Update time remaining notes in README Amend tests with new arguments Remove unused import Separate into time module Move to dictionary structure options Explicitly show time text Amend tests for separate module Remove old code Pass testdata as dict instead of kwargs Merge dictionaries for defaults Test almost working Delete settings.json Revert "Test almost working" This reverts commit f17d50681cae664719f67a7e8cc0b1feaf1ac4c7. Back to working state Remove unhelpful test Update docs Working without updated test Add tests for time remaining text Elapsed / Remaining Time on Progress Bar parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Jack McKew <jackmckew2@gmail.com> 1594344614 +1000 committer Jack McKew <jackmckew2@gmail.com> 1594346638 +1000 Elapsed / Remaining Time on Progress Bar parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246420 +1000 parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246359 +1000 Elapsed / Remaining Time on Progress Bar Elapsed / Remaining Time on Progress Bar Time Remaining Text for Progress Time remaining somewhat working Time format working Add tests and pythn 2.7 compat Incase python 2 import perf counter in func Fix flickering text and align Remove transactUI Add new decorators Update time remaining notes in README Amend tests with new arguments Remove unused import Separate into time module Move to dictionary structure options Explicitly show time text Amend tests for separate module Integration test - missing on complete tests Remove old code Elapsed / Remaining Time on Progress Bar parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246420 +1000 parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246359 +1000 Elapsed / Remaining Time on Progress Bar Elapsed / Remaining Time on Progress Bar Time Remaining Text for Progress Time remaining somewhat working Time format working Add tests and pythn 2.7 compat Incase python 2 import perf counter in func Fix flickering text and align Remove transactUI Add new decorators Update time remaining notes in README Amend tests with new arguments Remove unused import Separate into time module Move to dictionary structure options Explicitly show time text Amend tests for separate module Remove old code Pass testdata as dict instead of kwargs Merge dictionaries for defaults Test almost working Delete settings.json Revert "Test almost working" This reverts commit f17d50681cae664719f67a7e8cc0b1feaf1ac4c7. Back to working state Remove unhelpful test Update docs Working without updated test Add tests for time remaining text Remove artifact from squashing Amend artifacts Handle no progress and tidy up footer label
4 years ago
Elapsed / Remaining Time on Progress Bar parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Jack McKew <jackmckew2@gmail.com> 1594344614 +1000 committer Jack McKew <jackmckew2@gmail.com> 1594346638 +1000 Elapsed / Remaining Time on Progress Bar parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246420 +1000 parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246359 +1000 Elapsed / Remaining Time on Progress Bar Elapsed / Remaining Time on Progress Bar Time Remaining Text for Progress Time remaining somewhat working Time format working Add tests and pythn 2.7 compat Incase python 2 import perf counter in func Fix flickering text and align Remove transactUI Add new decorators Update time remaining notes in README Amend tests with new arguments Remove unused import Separate into time module Move to dictionary structure options Explicitly show time text Amend tests for separate module Integration test - missing on complete tests Remove old code Elapsed / Remaining Time on Progress Bar parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246420 +1000 parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246359 +1000 Elapsed / Remaining Time on Progress Bar Elapsed / Remaining Time on Progress Bar Time Remaining Text for Progress Time remaining somewhat working Time format working Add tests and pythn 2.7 compat Incase python 2 import perf counter in func Fix flickering text and align Remove transactUI Add new decorators Update time remaining notes in README Amend tests with new arguments Remove unused import Separate into time module Move to dictionary structure options Explicitly show time text Amend tests for separate module Remove old code Pass testdata as dict instead of kwargs Merge dictionaries for defaults Test almost working Delete settings.json Revert "Test almost working" This reverts commit f17d50681cae664719f67a7e8cc0b1feaf1ac4c7. Back to working state Remove unhelpful test Update docs Working without updated test Add tests for time remaining text Elapsed / Remaining Time on Progress Bar parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Jack McKew <jackmckew2@gmail.com> 1594344614 +1000 committer Jack McKew <jackmckew2@gmail.com> 1594346638 +1000 Elapsed / Remaining Time on Progress Bar parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246420 +1000 parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246359 +1000 Elapsed / Remaining Time on Progress Bar Elapsed / Remaining Time on Progress Bar Time Remaining Text for Progress Time remaining somewhat working Time format working Add tests and pythn 2.7 compat Incase python 2 import perf counter in func Fix flickering text and align Remove transactUI Add new decorators Update time remaining notes in README Amend tests with new arguments Remove unused import Separate into time module Move to dictionary structure options Explicitly show time text Amend tests for separate module Integration test - missing on complete tests Remove old code Elapsed / Remaining Time on Progress Bar parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246420 +1000 parent 00e0f3e7c6434240ffe02522a0be2daf8c5b456c author Fizban <jackmckew2@gmail.com> 1593182730 +1000 committer Fizban <jackmckew2@gmail.com> 1593246359 +1000 Elapsed / Remaining Time on Progress Bar Elapsed / Remaining Time on Progress Bar Time Remaining Text for Progress Time remaining somewhat working Time format working Add tests and pythn 2.7 compat Incase python 2 import perf counter in func Fix flickering text and align Remove transactUI Add new decorators Update time remaining notes in README Amend tests with new arguments Remove unused import Separate into time module Move to dictionary structure options Explicitly show time text Amend tests for separate module Remove old code Pass testdata as dict instead of kwargs Merge dictionaries for defaults Test almost working Delete settings.json Revert "Test almost working" This reverts commit f17d50681cae664719f67a7e8cc0b1feaf1ac4c7. Back to working state Remove unhelpful test Update docs Working without updated test Add tests for time remaining text Remove artifact from squashing Amend artifacts Handle no progress and tidy up footer label
4 years ago
2 years ago
2 years ago
  1. import sys
  2. import wx # type: ignore
  3. from gooey.gui import events
  4. from gooey.gui.lang.i18n import _
  5. from gooey.gui.pubsub import pub
  6. from gooey.gui.components.mouse import notifyMouseEvent
  7. class Footer(wx.Panel):
  8. '''
  9. Footer section used on the configuration
  10. screen of the application
  11. '''
  12. def __init__(self, parent, buildSpec, **kwargs):
  13. wx.Panel.__init__(self, parent, **kwargs)
  14. self.buildSpec = buildSpec
  15. self.SetMinSize((30, 53))
  16. # TODO: The was set to True for the timer addition
  17. # however, it leads to 'tearing' issues when resizing
  18. # the GUI in windows. Disabling until I can dig into it.
  19. self.SetDoubleBuffered(False)
  20. # components
  21. self.cancel_button = None
  22. self.start_button = None
  23. self.progress_bar = None
  24. self.close_button = None
  25. self.stop_button = None
  26. self.restart_button = None
  27. self.edit_button = None
  28. self.buttons = []
  29. self.layouts = {}
  30. self._init_components()
  31. self._do_layout()
  32. for button in self.buttons:
  33. self.Bind(wx.EVT_BUTTON, self.dispatch_click, button)
  34. self.Bind(wx.EVT_LEFT_DOWN, notifyMouseEvent, button)
  35. self.Bind(wx.EVT_LEFT_DOWN, notifyMouseEvent)
  36. def updateTimeRemaining(self,*args,**kwargs):
  37. estimate_time_remaining = kwargs.get('estimatedRemaining')
  38. elapsed_time_value = kwargs.get('elapsed_time')
  39. if elapsed_time_value is None:
  40. return
  41. elif estimate_time_remaining is not None:
  42. self.time_remaining_text.SetLabel(f"{elapsed_time_value}<{estimate_time_remaining}")
  43. return
  44. else:
  45. self.time_remaining_text.SetLabel(f"{elapsed_time_value}")
  46. def updateProgressBar(self, *args, **kwargs):
  47. '''
  48. value, disable_animation=False
  49. :param args:
  50. :param kwargs:
  51. :return:
  52. '''
  53. value = kwargs.get('progress')
  54. pb = self.progress_bar
  55. if value is None:
  56. return
  57. if value < 0:
  58. pb.Pulse()
  59. else:
  60. value = min(int(value), pb.GetRange())
  61. if pb.GetValue() != value:
  62. # Windows 7 progress bar animation hack
  63. # http://stackoverflow.com/questions/5332616/disabling-net-progressbar-animation-when-changing-value
  64. if self.buildSpec['disable_progress_bar_animation'] \
  65. and sys.platform.startswith("win"):
  66. if pb.GetRange() == value:
  67. pb.SetValue(value)
  68. pb.SetValue(value - 1)
  69. else:
  70. pb.SetValue(value + 1)
  71. pb.SetValue(value)
  72. def showButtons(self, *buttonsToShow):
  73. for button in self.buttons:
  74. button.Show(False)
  75. for button in buttonsToShow:
  76. getattr(self, button).Show(True)
  77. self.Layout()
  78. def _init_components(self):
  79. self.cancel_button = self.button(_('cancel'), wx.ID_CANCEL, event_id=events.WINDOW_CANCEL)
  80. self.stop_button = self.button(_('stop'), wx.ID_OK, event_id=events.WINDOW_STOP)
  81. self.start_button = self.button(_('start'), wx.ID_OK, event_id=int(events.WINDOW_START))
  82. self.close_button = self.button(_("close"), wx.ID_OK, event_id=int(events.WINDOW_CLOSE))
  83. self.restart_button = self.button(_('restart'), wx.ID_OK, event_id=int(events.WINDOW_RESTART))
  84. self.edit_button = self.button(_('edit'), wx.ID_OK, event_id=int(events.WINDOW_EDIT))
  85. self.progress_bar = wx.Gauge(self, range=100)
  86. self.time_remaining_text = wx.StaticText(self)
  87. self.buttons = [self.cancel_button, self.start_button,
  88. self.stop_button, self.close_button,
  89. self.restart_button, self.edit_button]
  90. if self.buildSpec['disable_stop_button']:
  91. self.stop_button.Enable(False)
  92. def _do_layout(self):
  93. self.SetBackgroundColour(self.buildSpec['footer_bg_color'])
  94. self.stop_button.Hide()
  95. self.restart_button.Hide()
  96. v_sizer = wx.BoxSizer(wx.VERTICAL)
  97. h_sizer = wx.BoxSizer(wx.HORIZONTAL)
  98. h_sizer.Add(self.progress_bar, 1,
  99. wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 20)
  100. h_sizer.Add(self.time_remaining_text,0,wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 20)
  101. h_sizer.AddStretchSpacer(1)
  102. h_sizer.Add(self.cancel_button, 0,wx.RIGHT, 20)
  103. h_sizer.Add(self.start_button, 0, wx.RIGHT, 20)
  104. h_sizer.Add(self.stop_button, 0, wx.RIGHT, 20)
  105. v_sizer.AddStretchSpacer(1)
  106. v_sizer.Add(h_sizer, 0, wx.EXPAND)
  107. h_sizer.Add(self.edit_button, 0, wx.RIGHT, 10)
  108. h_sizer.Add(self.restart_button, 0, wx.RIGHT, 10)
  109. h_sizer.Add(self.close_button, 0, wx.RIGHT, 20)
  110. self.edit_button.Hide()
  111. self.restart_button.Hide()
  112. self.close_button.Hide()
  113. # self.progress_bar.Hide()
  114. v_sizer.AddStretchSpacer(1)
  115. self.SetSizer(v_sizer)
  116. def button(self, label=None, style=None, event_id=-1):
  117. return wx.Button(
  118. parent=self,
  119. id=event_id,
  120. size=(90, -1),
  121. label=label,
  122. style=style)
  123. def dispatch_click(self, event):
  124. if event.EventObject.Enabled:
  125. pub.send_message(event.GetId())
  126. def hide_all_buttons(self):
  127. for button in self.buttons:
  128. button.Hide()