For example, pb = AFXProgressBar(parent, keyword, tgt, LAYOUT_FIX_HEIGHT|LAYOUT_FIX_WIDTH| FRAME_SUNKEN|FRAME_THICK|AFXPROGRESSBAR_SCANNER, 0, 0, 200, 25)If you want to control the display of the progress bar you can use the percentage or iterator mode and call setProgress with the appropriate value. from abaqusGui import * class MyDB(AFXDataDialog): ID_START = AFXDataDialog.ID_LAST def __init__(self, form): AFXDataDialog.__init__(self, form, 'My Dialog', self.OK|self.CANCEL, DECOR_RESIZE|DIALOG_ACTIONS_SEPARATOR) FXButton(self, 'Start Something', None, self, self.ID_START) FXMAPFUNC(self, SEL_COMMAND, self.ID_START, MyDB.onDoSomething) self.scannerDB = ScannerDB(self) def onDoSomething(self, sender, sel, ptr): self.scannerDB.create() self.scannerDB.showModal(self) getAFXApp().repaint() files = [ 'file_1.txt', 'file_2.txt', 'file_3.txt', 'file_4.txt', ] self.scannerDB.setTotal( len(files) ) for i in range( 1, len(files)+1 ): self.scannerDB.setProgress(i) # Do something with files[i] self.scannerDB.hide() class ScannerDB(AFXDialog): def __init__(self, owner): AFXDialog.__init__(self, owner, 'Work in Progress', 0, 0, DIALOG_ACTIONS_NONE) self.scanner = AFXProgressBar(self, None, 0, LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT| FRAME_SUNKEN|FRAME_THICK|AFXPROGRESSBAR_ITERATOR, 0, 0, 200, 22) def setTotal(self, total): self.scanner.setTotal(total) def setProgress(self, progress): self.scanner.setProgress(progress) Note: The setProgress method has no effect on a progress bar that uses the scanner mode. The progress bar has several different modes, as shown in Figure 1. Figure 1. Three modes of the progress bar widget.
|