def __init__(self, defered, automatique, parent, nbanswers): super(DAdditionnalquestions, self).__init__(parent) self._defered = defered self._automatique = automatique self._nbanswers = nbanswers layout = QtGui.QVBoxLayout(self) self._widanswers = WSpinbox( label=texts_TC.get_text_reponses(nbanswers), minimum=0, maximum=nbanswers, automatique=self._automatique, parent=self) layout.addWidget(self._widanswers) if pms.TREATMENT == pms.get_treatment("avec_communication"): self._widinfosatisfaction = WSlider( label=texts_TC.get_text_infosatisfaction(), minimum=1, maximum=7, automatique=self._automatique, parent=self) layout.addWidget(self._widinfosatisfaction) self._widjobsatisfaction = WSlider( label=texts_TC.get_text_jobsatisfaction(), minimum=1, maximum=7, automatique=self._automatique, parent=self) layout.addWidget(self._widjobsatisfaction) buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) buttons.accepted.connect(self._accept) layout.addWidget(buttons) if self._automatique: self._timer = QtCore.QTimer() self._timer.timeout.connect( buttons.button(QtGui.QDialogButtonBox.Ok).click) self._timer.start(7000) self.setWindowTitle(trans_TC(u"Additionnal questions")) self.adjustSize() self.setFixedSize(self.size())
class DAdditionnalquestions(QtGui.QDialog): def __init__(self, defered, automatique, parent, nbanswers): super(DAdditionnalquestions, self).__init__(parent) self._defered = defered self._automatique = automatique self._nbanswers = nbanswers layout = QtGui.QVBoxLayout(self) self._widanswers = WSpinbox( label=texts_TC.get_text_reponses(nbanswers), minimum=0, maximum=nbanswers, automatique=self._automatique, parent=self) layout.addWidget(self._widanswers) if pms.TREATMENT == pms.get_treatment("avec_communication"): self._widinfosatisfaction = WSlider( label=texts_TC.get_text_infosatisfaction(), minimum=1, maximum=7, automatique=self._automatique, parent=self) layout.addWidget(self._widinfosatisfaction) self._widjobsatisfaction = WSlider( label=texts_TC.get_text_jobsatisfaction(), minimum=1, maximum=7, automatique=self._automatique, parent=self) layout.addWidget(self._widjobsatisfaction) buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) buttons.accepted.connect(self._accept) layout.addWidget(buttons) if self._automatique: self._timer = QtCore.QTimer() self._timer.timeout.connect( buttons.button(QtGui.QDialogButtonBox.Ok).click) self._timer.start(7000) self.setWindowTitle(trans_TC(u"Additionnal questions")) self.adjustSize() self.setFixedSize(self.size()) def reject(self): pass def _accept(self): try: self._timer.stop() except AttributeError: pass rep = {"TC_confidence": self._widanswers.get_value(), "TC_jobsatisfaction": self._widjobsatisfaction.get_value()} if pms.TREATMENT == pms.get_treatment("avec_communication"): rep["TC_infosatisfaction"] = self._widinfosatisfaction.get_value() if not self._automatique: confirm = QtGui.QMessageBox.question( self, u"Confirmation", trans_TC(u"Do you confirm your answers?"), QtGui.QMessageBox.No | QtGui.QMessageBox.Yes) if confirm != QtGui.QMessageBox.Yes: return logger.info(u"Renvoi {}".format(rep)) self.accept() self._defered.callback(rep)