def __init__(self, file_name, title="Set Title!"): wx.Dialog.__init__(self, None, -1, title) if (paths.get_platform() != "mac"): co = wx.ColourDatabase().Find("light grey") #print co #self.SetBackgroundColour(co) self.SetBackgroundColour("lightgrey") #print self.GetBackgroundColour() self.progress_prompt = wx.StaticText(self, -1, "Download progress:") if (USE_WINSOUND): self.gauge = wx.StaticText(self, -1, "") else: self.gauge = wx.Gauge(self, -1, range=100) self.gauge.SetMinSize((500, -1)) self.start = wx.Button(self, -1, "Start Download") self.cancel = wx.Button(self, -1, "Cancel Download") self.help_text = wx.StaticText(self, -1, "") grid = wx.FlexGridSizer(3, 1, 5, 5) grid.Add(self.progress_prompt) grid.Add(self.gauge, flag=wx.EXPAND) grid.Add(self.help_text, flag=wx.EXPAND) buttons = wx.BoxSizer(wx.HORIZONTAL) buttons.AddStretchSpacer() buttons.Add(self.cancel) buttons.Add(self.start, flag=wx.LEFT, border=10) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(grid, 1, flag=wx.ALL, border=10) sizer.Add(buttons, 0, wx.EXPAND | wx.ALL, border=10) self.SetSizer(sizer) sizer.Fit(self) self.Layout() self.start.SetDefault() self.Bind(wx.EVT_BUTTON, self.on_start, self.start) self.Bind(wx.EVT_BUTTON, self.on_cancel, self.cancel) self.download_bytes, self.dtype, self.version = get_bytes(file_name) self.byte_count = len(self.download_bytes) if (USE_WINSOUND): self.gauge.SetLabel("") else: self.gauge.SetRange(self.byte_count) self.gauge.SetValue(0) self.help_text.SetLabel("Download size is %d bytes" % (self.byte_count, )) # convert to wav file WAV_FILE = os.path.join(paths.get_store_dir(), "program.wav") convertWithPause(self.download_bytes, WAV_FILE, DOWNLOAD_PAUSE_MSECS, DOWNLOAD_BYTES_BETWEEN_PAUSES)
def __init__(self, file_name, title="Set Title!"): wx.Dialog.__init__(self, None, -1, title) if (paths.get_platform() != "mac"): co = wx.ColourDatabase().Find("light grey") #print co #self.SetBackgroundColour(co) self.SetBackgroundColour("lightgrey") #print self.GetBackgroundColour() self.progress_prompt = wx.StaticText(self, -1, "Download progress:") if (USE_WINSOUND): self.gauge = wx.StaticText(self, -1, "") else: self.gauge = wx.Gauge(self, -1, range=100) self.gauge.SetMinSize((500, -1)) self.start = wx.Button(self, -1, "Start Download") self.cancel = wx.Button(self, -1, "Cancel Download") self.help_text = wx.StaticText(self, -1, "") grid = wx.FlexGridSizer(3 ,1, 5, 5) grid.Add(self.progress_prompt) grid.Add(self.gauge, flag=wx.EXPAND) grid.Add(self.help_text, flag=wx.EXPAND) buttons = wx.BoxSizer(wx.HORIZONTAL) buttons.AddStretchSpacer() buttons.Add(self.cancel) buttons.Add(self.start, flag=wx.LEFT, border=10) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(grid, 1, flag=wx.ALL, border=10) sizer.Add(buttons, 0, wx.EXPAND | wx.ALL, border=10) self.SetSizer(sizer) sizer.Fit(self) self.Layout() self.start.SetDefault() self.Bind(wx.EVT_BUTTON, self.on_start, self.start) self.Bind(wx.EVT_BUTTON, self.on_cancel, self.cancel) self.download_bytes, self.dtype, self.version = get_bytes(file_name) self.byte_count = len(self.download_bytes) if (USE_WINSOUND): self.gauge.SetLabel("") else: self.gauge.SetRange(self.byte_count) self.gauge.SetValue(0) self.help_text.SetLabel("Download size is %d bytes" % (self.byte_count,)) # convert to wav file WAV_FILE = os.path.join(paths.get_store_dir(), "program.wav") convertWithPause(self.download_bytes, WAV_FILE, DOWNLOAD_PAUSE_MSECS, DOWNLOAD_BYTES_BETWEEN_PAUSES);
def write_code(file_name): if (not file_name): file_name = os.path.join(paths.get_store_dir(), "last_compile") parts = os.path.splitext(file_name) file_name = parts[0] + ".mbc" file_handle = file(file_name, 'w') win_data.get_all_code(file_handle) file_handle.close() return file_name
def write_code(file_name): if (not file_name): file_name = os.path.join(paths.get_store_dir(), "last_compile") parts = os.path.splitext(file_name) file_name = parts[0]+".mbc" file_handle = file(file_name, 'w') win_data.get_all_code(file_handle) file_handle.close() return file_name
def loadRamp(): """See if there is a ramp file to be loaded to replace the default RAMP""" global RAMP RAMP = DEFAULT_RAMP # print "INFO - attempting to load new ramp data" lines = None ramp_path = os.path.join(paths.get_store_dir(), "ramp_override.txt") if (os.path.isfile(ramp_path)): try: fh = file(ramp_path, 'r') lines = fh.readlines() fh.close() except Exception: lines = None try: if (lines is not None): last_value = 0 new_ramp_data = [] for l in lines: number = l.strip(" \t\r\n") if (number.isdigit()): data = int(number) if (data < last_value) or (data > 100): print "WARN - Ramp value makes no sense! - using defaults" new_ramp_data = [] break else: new_ramp_data.append(data) last_value = data else: pass # skip the non-number if (len(new_ramp_data) > 0): print "INFO - New ramp data:", new_ramp_data RAMP = new_ramp_data except Exception: print "WARN - Error reading ramp_override.txt - using defaults!"
def on_start(self, event): # can't start twice so disable this button self.start.Disable() self.cancel.Disable() self.help_text.SetLabel("Downloading %d bytes." % (self.byte_count, )) if (USE_WINSOUND): self.gauge.SetLabel("...DOWNLOADING...") else: self.gauge.SetValue(0) self.gauge.Update() self.Update() time.sleep(1) WAV_FILE = os.path.join(paths.get_store_dir(), "program.wav") if USE_WAVER: startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW logfile_path = os.path.join(tempfile.gettempdir(), "waver.log") logfile = open(logfile_path, "a+") logfile.seek(0, os.SEEK_END) waver_path = os.path.join(paths.get_run_dir(), "waver", "waver.exe") process = subprocess.Popen([waver_path, WAV_FILE], startupinfo=startupinfo, stdout=logfile) process.wait() logfile.close() elif USE_PORTAUDIO: wf = wave.open(WAV_FILE, 'rb') p = pyaudio.PyAudio() totalFrames = wf.getnframes() framesRead = 0 self.gauge.SetRange(totalFrames) self.gauge.SetValue(0) stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), channels=wf.getnchannels(), rate=wf.getframerate(), output=True) data = wf.readframes(47) framesRead += 47 # print framesRead if (framesRead > totalFrames): framesRead = totalFrames stream.write(data) while data != '': stream.write(data) self.gauge.SetValue(framesRead) self.Update() data = wf.readframes(AUDIO_CHUNK) framesRead += AUDIO_CHUNK if (framesRead > totalFrames): framesRead = totalFrames #print framesRead self.gauge.SetValue(totalFrames) self.Update() correction = float(stream.get_write_available() - 32) / WAVE_SAMPLE_RATE_HZ #print correction time.sleep(stream.get_output_latency() - correction) stream.stop_stream() stream.close() p.terminate() elif USE_PYGAME: if (pygame.mixer.get_init() == None): pygame.mixer.init(frequency=WAVE_SAMPLE_RATE_HZ, size=8, channels=2, buffer=4096) pygame.mixer.init() s = pygame.mixer.Sound(WAV_FILE) seconds = s.get_length() #print "Sounds seconds:", seconds if (seconds < 1): seconds = 1 self.gauge.SetRange(seconds * 5) self.gauge.SetValue(0) elapsed = 0 s.play() while ((elapsed < seconds) and pygame.mixer.get_busy()): time.sleep(0.2) elapsed += 0.2 if (elapsed < seconds): self.gauge.SetValue(elapsed * 5) self.Update() self.gauge.SetValue(seconds * 5) self.Update() elif USE_WINSOUND: s1 = wx.Sound(WAV_FILE) s1.Play(wx.SOUND_SYNC) self.gauge.SetLabel("") self.help_text.SetLabel("Finished downloading") self.start.Enable() self.cancel.Enable() self.Refresh()
def on_start(self, event): # get the device #device = self.usb_ctrl.GetValue() device = None ## if (not os.path.exists(device) or not os.access(device, os.R_OK|os.W_OK)): ## self.help_text.SetLabel("ERROR - device %s doesn't exist or isn't readable and writable." % (device)) ## return # can't start twice so disable this button self.start.Disable() self.help_text.SetLabel("Starting download of %d bytes." % (self.byte_count,)) self.gauge.SetValue(0) self.gauge.Update() self.Update() time.sleep(1) WAV_FILE = os.path.join(paths.get_store_dir(), "program.wav") if USE_PORTAUDIO: wf = wave.open(WAV_FILE, 'rb') p = pyaudio.PyAudio() totalFrames = wf.getnframes() framesRead = 0 self.gauge.SetRange(totalFrames) self.gauge.SetValue(0) stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), channels=wf.getnchannels(), rate=wf.getframerate(), output=True) data = wf.readframes(AUDIO_CHUNK) framesRead += AUDIO_CHUNK if (framesRead > totalFrames): framesRead = totalFrames while data != '': stream.write(data) self.gauge.SetValue(framesRead) self.Update() data = wf.readframes(AUDIO_CHUNK) framesRead += AUDIO_CHUNK if (framesRead > totalFrames): framesRead = totalFrames self.gauge.SetValue(totalFrames) self.Update() stream.stop_stream() stream.close() p.terminate() elif USE_PYGAME: if (pygame.mixer.get_init() == None): pygame.mixer.init(frequency=44100, size=8, channels=2, buffer=4096) pygame.mixer.init() s = pygame.mixer.Sound(WAV_FILE) seconds = s.get_length() #print "Sounds seconds:", seconds if (seconds < 1): seconds = 1 self.gauge.SetRange(seconds * 5) self.gauge.SetValue(0) elapsed = 0 s.play() while ((elapsed < seconds) and pygame.mixer.get_busy()): time.sleep(0.2) elapsed += 0.2 if (elapsed < seconds): self.gauge.SetValue(elapsed * 5) self.Update() self.gauge.SetValue(seconds * 5) self.Update() elif paths.get_platform() == "win": s1 = wx.Sound(WAV_FILE) s1.Play(wx.SOUND_SYNC) #self.gauge.SetValue(self.byte_count) self.help_text.SetLabel("Finished downloading") self.start.Enable() self.Refresh()
def on_start(self, event): filename = self.file_browse.GetValue() if (not os.path.exists(filename)): self.help_text.SetLabel("Error - couldn't read file: %s" % (filename, )) return # Assuming that the file is the binary firmware file with all header bytes # already added. Just have to convert to audio and play. file_handle = file(filename, 'rb') firmware_string = file_handle.read() file_handle.close() self.download_bytes = bytearray(firmware_string) self.byte_count = len(self.download_bytes) if any([USE_WINSOUND, USE_WAVER]): self.gauge.SetLabel("") else: self.gauge.SetRange(self.byte_count) self.gauge.SetValue(0) self.help_text.SetLabel("Creating audio file.") self.Update() FIRMWARE_WAV = os.path.join(paths.get_store_dir(), "firmware.wav") # convert to wav file convertWithPause(self.download_bytes, FIRMWARE_WAV, DOWNLOAD_PAUSE_MSECS, DOWNLOAD_BYTES_BETWEEN_PAUSES) # can't start twice so disable this button self.start.Disable() self.cancel.Disable() self.help_text.SetLabel("Downloading %d bytes." % (self.byte_count, )) self.gauge.SetLabel("...DOWNLOADING...") self.Update() time.sleep(1) if USE_WAVER: startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW logfile_path = os.path.join(tempfile.gettempdir(), "waver.log") logfile = open(logfile_path, "a+") logfile.seek(0, os.SEEK_END) waver_path = os.path.join(paths.get_run_dir(), "waver", "waver.exe") process = subprocess.Popen([waver_path, FIRMWARE_WAV], startupinfo=startupinfo, stdout=logfile) process.wait() logfile.close() elif USE_PORTAUDIO: wf = wave.open(FIRMWARE_WAV, 'rb') p = pyaudio.PyAudio() totalFrames = wf.getnframes() framesRead = 0 self.gauge.SetRange(totalFrames) self.gauge.SetValue(0) stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), channels=wf.getnchannels(), rate=wf.getframerate(), output=True) data = wf.readframes(47) framesRead += 47 if (framesRead > totalFrames): framesRead = totalFrames stream.write(data) while data != '': stream.write(data) self.gauge.SetValue(framesRead) self.Update() data = wf.readframes(AUDIO_CHUNK) framesRead += AUDIO_CHUNK if (framesRead > totalFrames): framesRead = totalFrames self.gauge.SetValue(totalFrames) self.Update() correction = float(stream.get_write_available() - 32) / sample_rate time.sleep(stream.get_output_latency() - correction) stream.stop_stream() stream.close() p.terminate() elif USE_PYGAME: if (pygame.mixer.get_init() == None): pygame.mixer.init(frequency=44100, size=8, channels=2, buffer=4096) pygame.mixer.init() s = pygame.mixer.Sound(FIRMWARE_WAV) seconds = s.get_length() #print "Sounds seconds:", seconds if (seconds < 1): seconds = 1 self.gauge.SetRange(seconds * 5) self.gauge.SetValue(0) elapsed = 0 s.play() while ((elapsed < seconds) and pygame.mixer.get_busy()): time.sleep(0.2) elapsed += 0.2 if (elapsed < seconds): self.gauge.SetValue(elapsed * 5) self.Update() self.gauge.SetValue(seconds * 5) self.Update() self.gauge.SetLabel("") self.help_text.SetLabel("Finished downloading") self.start.Enable() self.cancel.Enable() self.Refresh()
def on_start(self, event): # can't start twice so disable this button self.start.Disable() self.cancel.Disable() self.help_text.SetLabel("Downloading %d bytes." % (self.byte_count,)) if (USE_WINSOUND): self.gauge.SetLabel("...DOWNLOADING...") else: self.gauge.SetValue(0) self.gauge.Update() self.Update() time.sleep(1) WAV_FILE = os.path.join(paths.get_store_dir(), "program.wav") if USE_WAVER: startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW logfile_path = os.path.join(tempfile.gettempdir(), "waver.log") logfile = open(logfile_path, "a+") logfile.seek(0, os.SEEK_END) waver_path = os.path.join(paths.get_run_dir(), "waver", "waver.exe") process = subprocess.Popen([waver_path, WAV_FILE], startupinfo=startupinfo, stdout=logfile) process.wait() logfile.close() elif USE_PORTAUDIO: wf = wave.open(WAV_FILE, 'rb') p = pyaudio.PyAudio() totalFrames = wf.getnframes() framesRead = 0 self.gauge.SetRange(totalFrames) self.gauge.SetValue(0) stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), channels=wf.getnchannels(), rate=wf.getframerate(), output=True) data = wf.readframes(47) framesRead += 47 # print framesRead if (framesRead > totalFrames): framesRead = totalFrames stream.write(data) while data != '': stream.write(data) self.gauge.SetValue(framesRead) self.Update() data = wf.readframes(AUDIO_CHUNK) framesRead += AUDIO_CHUNK if (framesRead > totalFrames): framesRead = totalFrames #print framesRead self.gauge.SetValue(totalFrames) self.Update() correction = float(stream.get_write_available() - 32)/WAVE_SAMPLE_RATE_HZ #print correction time.sleep(stream.get_output_latency() - correction) stream.stop_stream() stream.close() p.terminate() elif USE_PYGAME: if (pygame.mixer.get_init() == None): pygame.mixer.init(frequency=WAVE_SAMPLE_RATE_HZ, size=8, channels=2, buffer=4096) pygame.mixer.init() s = pygame.mixer.Sound(WAV_FILE) seconds = s.get_length() #print "Sounds seconds:", seconds if (seconds < 1): seconds = 1 self.gauge.SetRange(seconds * 5) self.gauge.SetValue(0) elapsed = 0 s.play() while ((elapsed < seconds) and pygame.mixer.get_busy()): time.sleep(0.2) elapsed += 0.2 if (elapsed < seconds): self.gauge.SetValue(elapsed * 5) self.Update() self.gauge.SetValue(seconds * 5) self.Update() elif USE_WINSOUND: s1 = wx.Sound(WAV_FILE) s1.Play(wx.SOUND_SYNC) self.gauge.SetLabel("") self.help_text.SetLabel("Finished downloading") self.start.Enable() self.cancel.Enable() self.Refresh()
def on_start(self, event): filename = self.file_browse.GetValue() if (not os.path.exists(filename)): self.help_text.SetLabel("Error - couldn't read file: %s" % (filename,)) return # Assuming that the file is the binary firmware file with all header bytes # already added. Just have to convert to audio and play. file_handle = file(filename, 'rb') firmware_string = file_handle.read() file_handle.close() self.download_bytes = bytearray(firmware_string) self.byte_count = len(self.download_bytes) if any([USE_WINSOUND, USE_WAVER]): self.gauge.SetLabel("") else: self.gauge.SetRange(self.byte_count) self.gauge.SetValue(0) self.help_text.SetLabel("Creating audio file.") self.Update() FIRMWARE_WAV = os.path.join(paths.get_store_dir(), "firmware.wav") # convert to wav file convertWithPause(self.download_bytes, FIRMWARE_WAV, DOWNLOAD_PAUSE_MSECS, DOWNLOAD_BYTES_BETWEEN_PAUSES); # can't start twice so disable this button self.start.Disable() self.cancel.Disable() self.help_text.SetLabel("Downloading %d bytes." % (self.byte_count,)) self.gauge.SetLabel("...DOWNLOADING...") self.Update() time.sleep(1) if USE_WAVER: startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW logfile_path = os.path.join(tempfile.gettempdir(), "waver.log") logfile = open(logfile_path, "a+") logfile.seek(0, os.SEEK_END) waver_path = os.path.join(paths.get_run_dir(), "waver", "waver.exe") process = subprocess.Popen([waver_path, FIRMWARE_WAV], startupinfo=startupinfo, stdout=logfile) process.wait() logfile.close() elif USE_PORTAUDIO: wf = wave.open(FIRMWARE_WAV, 'rb') p = pyaudio.PyAudio() totalFrames = wf.getnframes() framesRead = 0 self.gauge.SetRange(totalFrames) self.gauge.SetValue(0) stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), channels=wf.getnchannels(), rate=wf.getframerate(), output=True) data = wf.readframes(47) framesRead += 47 if (framesRead > totalFrames): framesRead = totalFrames stream.write(data) while data != '': stream.write(data) self.gauge.SetValue(framesRead) self.Update() data = wf.readframes(AUDIO_CHUNK) framesRead += AUDIO_CHUNK if (framesRead > totalFrames): framesRead = totalFrames self.gauge.SetValue(totalFrames) self.Update() correction = float(stream.get_write_available() - 32)/sample_rate time.sleep(stream.get_output_latency() - correction) stream.stop_stream() stream.close() p.terminate() elif USE_PYGAME: if (pygame.mixer.get_init() == None): pygame.mixer.init(frequency=44100, size=8, channels=2, buffer=4096) pygame.mixer.init() s = pygame.mixer.Sound(FIRMWARE_WAV) seconds = s.get_length() #print "Sounds seconds:", seconds if (seconds < 1): seconds = 1 self.gauge.SetRange(seconds * 5) self.gauge.SetValue(0) elapsed = 0 s.play() while ((elapsed < seconds) and pygame.mixer.get_busy()): time.sleep(0.2) elapsed += 0.2 if (elapsed < seconds): self.gauge.SetValue(elapsed * 5) self.Update() self.gauge.SetValue(seconds * 5) self.Update() self.gauge.SetLabel("") self.help_text.SetLabel("Finished downloading") self.start.Enable() self.cancel.Enable() self.Refresh()
def on_start(self, event): # can't start twice so disable this button self.start.Disable() self.cancel.Disable() self.help_text.SetLabel("Downloading %d bytes." % (self.byte_count,)) if (USE_WINSOUND): self.gauge.SetLabel("...DOWNLOADING...") else: self.gauge.SetValue(0) self.gauge.Update() self.Update() time.sleep(1) WAV_FILE = os.path.join(paths.get_store_dir(), "program.wav") if USE_PORTAUDIO: wf = wave.open(WAV_FILE, 'rb') p = pyaudio.PyAudio() totalFrames = wf.getnframes() framesRead = 0 self.gauge.SetRange(totalFrames) self.gauge.SetValue(0) stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), channels=wf.getnchannels(), rate=wf.getframerate(), output=True) data = wf.readframes(AUDIO_CHUNK) framesRead += AUDIO_CHUNK if (framesRead > totalFrames): framesRead = totalFrames while data != '': stream.write(data) self.gauge.SetValue(framesRead) self.Update() data = wf.readframes(AUDIO_CHUNK) framesRead += AUDIO_CHUNK if (framesRead > totalFrames): framesRead = totalFrames self.gauge.SetValue(totalFrames) self.Update() stream.stop_stream() stream.close() p.terminate() elif USE_PYGAME: if (pygame.mixer.get_init() == None): pygame.mixer.init(frequency=44100, size=8, channels=2, buffer=4096) pygame.mixer.init() s = pygame.mixer.Sound(WAV_FILE) seconds = s.get_length() #print "Sounds seconds:", seconds if (seconds < 1): seconds = 1 self.gauge.SetRange(seconds * 5) self.gauge.SetValue(0) elapsed = 0 s.play() while ((elapsed < seconds) and pygame.mixer.get_busy()): time.sleep(0.2) elapsed += 0.2 if (elapsed < seconds): self.gauge.SetValue(elapsed * 5) self.Update() self.gauge.SetValue(seconds * 5) self.Update() elif USE_WINSOUND: s1 = wx.Sound(WAV_FILE) s1.Play(wx.SOUND_SYNC) self.gauge.SetLabel("") self.help_text.SetLabel("Finished downloading") self.start.Enable() self.cancel.Enable() self.Refresh()
def on_start(self, event): # can't start twice so disable this button self.start.Disable() self.cancel.Disable() self.help_text.SetLabel("Downloading %d bytes." % (self.byte_count, )) if (USE_WINSOUND): self.gauge.SetLabel("...DOWNLOADING...") else: self.gauge.SetValue(0) self.gauge.Update() self.Update() time.sleep(1) WAV_FILE = os.path.join(paths.get_store_dir(), "program.wav") if USE_PORTAUDIO: wf = wave.open(WAV_FILE, 'rb') p = pyaudio.PyAudio() totalFrames = wf.getnframes() framesRead = 0 self.gauge.SetRange(totalFrames) self.gauge.SetValue(0) stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), channels=wf.getnchannels(), rate=wf.getframerate(), output=True) data = wf.readframes(AUDIO_CHUNK) framesRead += AUDIO_CHUNK if (framesRead > totalFrames): framesRead = totalFrames while data != '': stream.write(data) self.gauge.SetValue(framesRead) self.Update() data = wf.readframes(AUDIO_CHUNK) framesRead += AUDIO_CHUNK if (framesRead > totalFrames): framesRead = totalFrames self.gauge.SetValue(totalFrames) self.Update() stream.stop_stream() stream.close() p.terminate() elif USE_PYGAME: if (pygame.mixer.get_init() == None): pygame.mixer.init(frequency=44100, size=8, channels=2, buffer=4096) pygame.mixer.init() s = pygame.mixer.Sound(WAV_FILE) seconds = s.get_length() #print "Sounds seconds:", seconds if (seconds < 1): seconds = 1 self.gauge.SetRange(seconds * 5) self.gauge.SetValue(0) elapsed = 0 s.play() while ((elapsed < seconds) and pygame.mixer.get_busy()): time.sleep(0.2) elapsed += 0.2 if (elapsed < seconds): self.gauge.SetValue(elapsed * 5) self.Update() self.gauge.SetValue(seconds * 5) self.Update() elif USE_WINSOUND: s1 = wx.Sound(WAV_FILE) s1.Play(wx.SOUND_SYNC) self.gauge.SetLabel("") self.help_text.SetLabel("Finished downloading") self.start.Enable() self.cancel.Enable() self.Refresh()