コード例 #1
0
    def _updateValues(self, event):
        """
        Function to be called frequently for updating the controls on the dialog window.
        
        This function is called by the time every second. It gains the latest data from 
        the status instance and updates the values for the controls. The gauge for the 
        progress is just put forward a certain amount of progress.
        
        If the status instance indicates the end of the execution, the title of the dialog
        is either set to "finished" or to "error" depending on the value for error in the
        status instance.
        
        @param event: Event causing this function.
        """
        self._lSource.SetLabel("Source: " + self._settings.getSource())
        self._lDestination.SetLabel("Image File: " + self._settings.getDestination())
        starttime = Tools.processTime(int(self._status.getStartTime()) % (60 * 60 * 24))
        self._lStartTime.SetLabel("Start Time: " + starttime[0] + ":" + starttime[1] + ":" + starttime[2])

        elapsed = Tools.processTime(self._status.getElapsedTime())
        if self._status.getEndFilesize():
            self._lFilesize.SetLabel("File Size: %s / %s (%d %%)" %(self._formatSize(self._status.getDestinationFileSize()), self._formatSize(self._status.getEndFilesize()), (self._status.getDestinationFileSize() * 100 / self._status.getEndFilesize())))
            self._gauge.SetValue(int(self._status.getDestinationFileSize() * 10000 / self._status.getEndFilesize()))
            if  self._status.getDestinationFileSize() != 0 and  self._status.getEndFilesize() - self._status.getDestinationFileSize() != 0:
                remaining = self._status.getElapsedTime() / self._status.getDestinationFileSize() * (self._status.getEndFilesize() - self._status.getDestinationFileSize())
                remaining = Tools.processTime(remaining)
                self._lTimeElapsed.SetLabel("Time elapsed: " + elapsed[0] + ":" + elapsed[1] + ":" + elapsed[2] + "  (remaining: " + remaining[0] + ":" + remaining[1] + ":" + remaining[2] + ")")
        else:
            self._lFilesize.SetLabel("File Size: %s" %(self._formatSize(self._status.getDestinationFileSize())))
            val = self._gauge.GetValue()
            self._gauge.SetValue((val + 2000 ) % 10000)
            self._lTimeElapsed.SetLabel("Time elapsed: " + elapsed[0] + ":" + elapsed[1] + ":" + elapsed[2])
        
        
        if self._status.isFinished():
            if self._status.getError() != None:
                self._lTitle.SetLabel("Error whilst Imaging")
            else:
                self._lTitle.SetLabel("Imaging finished")
            self._lTimeElapsed.SetLabel("Time elapsed: " + elapsed[0] + ":" + elapsed[1] + ":" + elapsed[2])
            self._gauge.SetValue(10000)
            self._bOK.Enable(1)