Skip to content

Commit

Permalink
Use a ProgressDialog to display the recording timer
Browse files Browse the repository at this point in the history
Before this change we rolled-out our own custom (ugly) widget to display
the time remaining before recording. Now it's a built-in one.
  • Loading branch information
Mairo Rufus committed May 8, 2021
1 parent e234894 commit 4d5d358
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions atbswp/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

import settings

from custom_widgets import SliderDialog, CountdownDialog
from custom_widgets import SliderDialog

import wx
import wx.adv
Expand Down Expand Up @@ -315,11 +315,14 @@ def action(self, event):
except:
self.timer = 0

if event.GetEventObject().GetValue():
if event.EventObject.Value:
if self.timer > 0:
self.countdown_dialog = CountdownDialog(None, title="Wait for the recording to start", countdown=self.timer)
self.countdown_dialog = wx.ProgressDialog(title="Wait for the recording to start",
message=f"The recording will start in {self.timer} second(s)",
style=wx.PD_APP_MODAL)
self.countdown_dialog.Range = self.timer
self.wx_timer = wx.Timer(event.GetEventObject())
event.GetEventObject().Bind(wx.EVT_TIMER, self.update_timer, self.wx_timer)
event.EventObject.Bind(wx.EVT_TIMER, self.update_timer, self.wx_timer)
self.wx_timer.Start(1000)
self.countdown_dialog.ShowModal()

Expand Down Expand Up @@ -347,7 +350,9 @@ def update_timer(self, event):
self.wx_timer.Stop()
self.countdown_dialog.Destroy()
else:
self.timer = self.countdown_dialog.update_ui()
time.sleep(1)
self.timer -= 1
self.countdown_dialog.Update(self.timer, f"The recording will start in {self.timer} second(s)")


class PlayCtrl:
Expand Down

0 comments on commit 4d5d358

Please sign in to comment.