def __init__(self, doc): """Initialisation method for the View """ QWidget.__init__(self) self.doc = doc # The ui from designer is setup as self.ui self.ui = Ui_queuedReductionsUI() self.ui.setupUi(self) self.setGeometry(650, 100, 600, 400) # Add the relevant connections to populate UI elements self.ui.maskFileLineEdit.setText(self.doc.getMaskfile()) self.ui.directBeamLineEdit.setText( self.doc.getDirectBeam()) self.connect(self.ui.maskFilePushButtonQueue, SIGNAL("clicked()"), self.changeMaskFileForQueue) self.connect(self.ui.directBeamPushButtonQueue, SIGNAL("clicked()"), self.changeDirectBeamForQueue) self.connect(self.ui.cancelQueuePushButton, SIGNAL("clicked()"), self.cancelReductionQueue) self.connect(self.ui.reduceQueuePushButton, SIGNAL("clicked()"), self.doQueuedReductions) self.tablemodel = QueueTableModel(self.doc) self.ui.reductionQueueTableView.setModel(self.tablemodel)
class QueueWindowView(QWidget): """A view for showing which reductions are currently queued First implementation is just to show them and provide a reduce button. More complex version should allow removal of items from the queue. """ def __init__(self, doc): """Initialisation method for the View """ QWidget.__init__(self) self.doc = doc # The ui from designer is setup as self.ui self.ui = Ui_queuedReductionsUI() self.ui.setupUi(self) self.setGeometry(650, 100, 600, 400) # Add the relevant connections to populate UI elements self.ui.maskFileLineEdit.setText(self.doc.getMaskfile()) self.ui.directBeamLineEdit.setText( self.doc.getDirectBeam()) self.connect(self.ui.maskFilePushButtonQueue, SIGNAL("clicked()"), self.changeMaskFileForQueue) self.connect(self.ui.directBeamPushButtonQueue, SIGNAL("clicked()"), self.changeDirectBeamForQueue) self.connect(self.ui.cancelQueuePushButton, SIGNAL("clicked()"), self.cancelReductionQueue) self.connect(self.ui.reduceQueuePushButton, SIGNAL("clicked()"), self.doQueuedReductions) self.tablemodel = QueueTableModel(self.doc) self.ui.reductionQueueTableView.setModel(self.tablemodel) def changeMaskFileForQueue(self): """Method for changing the maskfile for queue This method needs to change the mask file for each reduction in the queue. There is currently no means of changing them independently through the GUI. """ maskfilepath = QFileDialog.getOpenFileName(self, 'Select Mask File', self.doc.getInPath()) self.ui.maskFileLineEdit.setText(maskfilepath) for reduction in self.doc.getReductionQueue(): reduction.setMaskfile(maskfilepath) def changeDirectBeamForQueue(self): """Method for changing the direct beam run for queue This method needs to change the direct beam run for each reduction in the queue. There is currently no means of changing them independently through the GUI. """ directbeampath = QFileDialog.getOpenFileName(self, 'Select Direct Beam', self.doc.getInPath()) directbeamrun = os.path.basename(str(directbeampath)).lstrip('SANS2D0') self.ui.directBeamLineEdit.setText(directbeamrun) for reduction in self.doc.getReductionQueue(): reduction.setDirectBeam(directbeamrun) def cancelReductionQueue(self): """Method for cancelling the queue This method will both close the queue window and clear the queue, allowing the user to start again with a new queue. """ self.doc.clearReductionQueue() self.close() self.destroy() def doQueuedReductions(self): """UI Calling method for doing the full set of reductions Calls the document method for doing the queued reductions and then kills the queue and closes the queue window. """ self.doc.doQueuedReductions() self.cancelReductionQueue()