Package Camelot :: Package camelot :: Package view :: Package wizard :: Package pages :: Module progress_page
[frames] | no frames]

Source Code for Module Camelot.camelot.view.wizard.pages.progress_page

 1  ''' 
 2  Created on Jan 7, 2010 
 3   
 4  @author: tw55413 
 5  ''' 
 6   
 7  from PyQt4 import QtCore, QtGui 
 8   
 9  from camelot.core.utils import ugettext_lazy as _ 
10   
11   
12 -class ProgressPage(QtGui.QWizardPage):
13 """Generic progress page for a wizard. 14 15 Subclass and reimplement the run method. And within this run method, 16 regulary emit the update_progress_signal and the update_maximum_signal. 17 18 the update_maximum_signal should have as its single argument an integer 19 value indicating the maximum of the progress bar. 20 21 the update_progress_signal should two arguments, the first is an integer 22 indicating the current position of the progress bar, and the second is 23 a string telling the user what is going on. 24 25 If required, set the title and sub_title class attribute to change the 26 text displayed to the user. 27 """ 28 29 update_progress_signal = QtCore.SIGNAL('update_progress') 30 update_maximum_signal = QtCore.SIGNAL('update_maximum') 31 32 title = _('Action in progress') 33 sub_title = _('Please wait for completion') 34
35 - def __init__(self, parent=None):
36 super(ProgressPage, self).__init__( parent ) 37 self.connect(self, self.update_progress_signal, self.update_progress) 38 self.connect(self, self.update_maximum_signal, self.update_maximum) 39 self._complete = False 40 self.setTitle(unicode(self.title)) 41 self.setSubTitle(unicode(self.sub_title)) 42 layout = QtGui.QVBoxLayout() 43 self.progress = QtGui.QProgressBar(self) 44 self.progress.setMinimum(0) 45 self.progress.setMaximum(1) 46 self.label = QtGui.QTextEdit(self) 47 self.label.setReadOnly(True) 48 layout.addWidget(self.progress) 49 layout.addWidget(self.label) 50 layout.addStretch(1) 51 self.setLayout(layout) 52 self._wizard = parent
53
54 - def isComplete(self):
55 return self._complete
56
57 - def update_maximum(self, maximum):
58 self.progress.setMaximum(maximum)
59
60 - def update_progress(self, value, label):
61 self.progress.setValue(value) 62 self.label.setHtml(unicode(label))
63
64 - def exception(self, args):
68
69 - def finished(self):
70 self._complete = True 71 self.progress.setMaximum(1) 72 self.progress.setValue(1) 73 self.emit(QtCore.SIGNAL('completeChanged()'))
74
75 - def run(self):
76 """ 77 This method contains the actual action, that will be run in the model thread. 78 79 Reimplement this method, while regulary emiting update_progress_signal and 80 update_maximum_signal to keep the progress bar moving. 81 """ 82 pass
83
84 - def initializePage(self):
85 from camelot.view.model_thread import post 86 post(self.run, self.finished, self.exception)
87