class DEchelle(QtGui.QDialog): def __init__(self, defered, automatique, parent, num_question): super(DEchelle, self).__init__(parent) self._defered = defered self._automatique = automatique layout = QtGui.QVBoxLayout(self) self._radios = WRadio( parent=self, automatique=self._automatique, label=texts_OL.get_text_question(num_question), texts=texts_OL.get_items_question(num_question)) layout.addWidget(self._radios) buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) buttons.accepted.connect(self._accept) layout.addWidget(buttons) self.setWindowTitle(le2mtrans(u"Question")) self.adjustSize() self.setFixedSize(self.size()) if self._automatique: self._timer_automatique = QtCore.QTimer() self._timer_automatique.timeout.connect( buttons.button(QtGui.QDialogButtonBox.Ok).click) self._timer_automatique.start(7000) def reject(self): pass def _accept(self): try: self._timer_automatique.stop() except AttributeError: pass try: checked = self._radios.get_checkedbutton() except ValueError: return QtGui.QMessageBox.warning( self, le2mtrans(u"Warning"), texts_OL.trans_OL(u"You must select one item")) if not self._automatique: confirm = QtGui.QMessageBox.question( self, le2mtrans(u"Confirmation"), le2mtrans(u"Do you confirm your choice?"), QtGui.QMessageBox.No | QtGui.QMessageBox.Yes) if confirm != QtGui.QMessageBox.Yes: return logger.info(u"Send back: {}".format(checked)) self.accept() self._defered.callback(checked)
class DEchelle(QtGui.QDialog): def __init__(self, defered, automatique, parent, num_question): super(DEchelle, self).__init__(parent) self._defered = defered self._automatique = automatique layout = QtGui.QVBoxLayout(self) self._radios = WRadio( parent=self, automatique=self._automatique, label=texts_VM.get_text_question(num_question), texts=texts_VM.get_items_question(num_question)) layout.addWidget(self._radios) buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) buttons.accepted.connect(self._accept) layout.addWidget(buttons) self.setWindowTitle(le2mtrans(u"Question")) self.adjustSize() self.setFixedSize(self.size()) if self._automatique: self._timer_automatique = QtCore.QTimer() self._timer_automatique.timeout.connect( buttons.button(QtGui.QDialogButtonBox.Ok).click) self._timer_automatique.start(7000) def reject(self): pass def _accept(self): try: self._timer_automatique.stop() except AttributeError: pass try: checked = self._radios.get_checkedbutton() except ValueError: return QtGui.QMessageBox.warning( self, le2mtrans(u"Warning"), texts_VM.trans_VM(u"You must select one item")) if not self._automatique: confirm = QtGui.QMessageBox.question( self, le2mtrans(u"Confirmation"), le2mtrans(u"Do you confirm your choice?"), QtGui.QMessageBox.No | QtGui.QMessageBox.Yes) if confirm != QtGui.QMessageBox.Yes: return logger.info(u"Send back: {}".format(checked)) self.accept() self._defered.callback(checked)
class DQuestFinalPGGS(DQuestFinal): def __init__(self, defered, automatique, parent): DQuestFinal.__init__(self, defered, automatique, parent) politics = [v for k, v in sorted(texts_PGGS.POLITICS.viewitems())] politics.insert(0, le2mtrans(u"Choose")) politics.append(le2mtrans(u"Not in the list above")) self._politics = WCombo( parent=self, automatique=self._automatique, label=texts_PGGS.trans_PGGS( u"Politically, you feel yourself in line with"), items=politics) self._gridlayout.addWidget(self._politics, 6, 1) self._risk = WRadio(parent=self, automatique=self._automatique, label=texts_PGGS.get_text_risk(), texts=map(str, range(11))) self._gridlayout.addWidget(self._risk, 7, 0, 1, 3) self._inequality = WRadio(parent=self, automatique=self._automatique, label=texts_PGGS.get_text_inequality(), texts=map(str, range(11))) self._gridlayout.addWidget(self._inequality, 8, 0, 1, 3) self.setMinimumSize(0, 0) self.setMaximumSize(16777215, 16777215) self.adjustSize() self.setFixedSize(self.size()) def _accept(self): try: self._timer_automatique.stop() except AttributeError: pass inputs = self._get_inputs() if type(inputs) is dict: try: inputs["politics"] = self._politics.get_currentindex() inputs["risk"] = self._risk.get_checkedbutton() inputs["inequality"] = self._inequality.get_checkedbutton() except ValueError: return QtGui.QMessageBox.warning( self, le2mtrans(u"Warning"), le2mtrans(u"You must answer to all the questions")) if not self._automatique: confirm = QtGui.QMessageBox.question( self, le2mtrans(u"Confirmation"), le2mtrans(u"Do you confirm your answers?"), QtGui.QMessageBox.No | QtGui.QMessageBox.Yes) if confirm != QtGui.QMessageBox.Yes: return logger.info(u"Send back: {}".format(inputs)) self.accept() self._defered.callback(inputs) else: return
class DVote(QtGui.QDialog): def __init__(self, defered, automatique, parent): super(DVote, self).__init__(parent) self._defered = defered self._automatique = automatique layout = QtGui.QVBoxLayout(self) self._explanation = WExplication( parent=self, text=texts_PGGS.get_text_vote(), size=(450, 80)) layout.addWidget(self._explanation) self._vote = WRadio( parent=self, automatique=self._automatique, label=texts_PGGS.trans_PGGS(u"Your vote"), texts=[v for k, v in sorted(texts_PGGS.VOTES.iteritems())]) layout.addWidget(self._vote) buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) buttons.accepted.connect(self._accept) layout.addWidget(buttons) self.setWindowTitle(texts_PGGS.trans_PGGS(u"Vote")) self.adjustSize() self.setFixedSize(self.size()) if self._automatique: self._timer = QtCore.QTimer() self._timer.timeout.connect( buttons.button(QtGui.QDialogButtonBox.Ok).click) self._timer.start(7000) def reject(self): pass def _accept(self): try: self._timer.stop() except AttributeError: pass try: vote = self._vote.get_checkedbutton() except ValueError: return QtGui.QMessageBox.warning( self, le2mtrans(u"Warning"), texts_PGGS.trans_PGGS(u"You must take a decision")) if not self._automatique: if QtGui.QMessageBox.question( self, le2mtrans(u"Confirmation"), le2mtrans(u"Do you confirm your choice"), QtGui.QMessageBox.No | QtGui.QMessageBox.Yes) != \ QtGui.QMessageBox.Yes: return logger.info(u"Send back {}".format(vote)) self.accept() self._defered.callback(vote)
class DQuestFinalPGGS(DQuestFinal): def __init__(self, defered, automatique, parent): DQuestFinal.__init__(self, defered, automatique, parent) politics = [v for k, v in sorted(texts_PGGS.POLITICS.items())] politics.insert(0, le2mtrans(u"Choose")) politics.append(le2mtrans(u"Not in the list above")) self._politics = WCombo( parent=self, automatique=self._automatique, label=texts_PGGS.trans_PGGS( u"Politically, you feel yourself in line with"), items=politics) self._gridlayout.addWidget(self._politics, 6, 1) self._risk = WRadio(parent=self, automatique=self._automatique, label=texts_PGGS.get_text_risk(), texts=map(str, range(11))) self._gridlayout.addWidget(self._risk, 7, 0, 1, 3) self._inequality = WRadio(parent=self, automatique=self._automatique, label=texts_PGGS.get_text_inequality(), texts=map(str, range(11))) self._gridlayout.addWidget(self._inequality, 8, 0, 1, 3) self.setMinimumSize(0, 0) self.setMaximumSize(16777215, 16777215) self.adjustSize() self.setFixedSize(self.size()) def _accept(self): try: self._timer_automatique.stop() except AttributeError: pass inputs = self._get_inputs() if type(inputs) is dict: try: inputs["politics"] = self._politics.get_currentindex() inputs["risk"] = self._risk.get_checkedbutton() inputs["inequality"] = self._inequality.get_checkedbutton() except ValueError: return QtGui.QMessageBox.warning( self, le2mtrans(u"Warning"), le2mtrans(u"You must answer to all the questions")) if not self._automatique: confirm = QtGui.QMessageBox.question( self, le2mtrans(u"Confirmation"), le2mtrans(u"Do you confirm your answers?"), QtGui.QMessageBox.No | QtGui.QMessageBox.Yes) if confirm != QtGui.QMessageBox.Yes: return logger.info(u"Send back: {}".format(inputs)) self.accept() self._defered.callback(inputs) else: return
class DVote(QtGui.QDialog): def __init__(self, defered, automatique, parent): super(DVote, self).__init__(parent) self._defered = defered self._automatique = automatique layout = QtGui.QVBoxLayout(self) self._explanation = WExplication(parent=self, text=texts_PGGS.get_text_vote(), size=(450, 80)) layout.addWidget(self._explanation) self._vote = WRadio( parent=self, automatique=self._automatique, label=texts_PGGS.trans_PGGS(u"Your vote"), texts=[v for k, v in sorted(texts_PGGS.VOTES.viewitems())]) layout.addWidget(self._vote) buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) buttons.accepted.connect(self._accept) layout.addWidget(buttons) self.setWindowTitle(texts_PGGS.trans_PGGS(u"Vote")) self.adjustSize() self.setFixedSize(self.size()) if self._automatique: self._timer = QtCore.QTimer() self._timer.timeout.connect( buttons.button(QtGui.QDialogButtonBox.Ok).click) self._timer.start(7000) def reject(self): pass def _accept(self): try: self._timer.stop() except AttributeError: pass try: vote = self._vote.get_checkedbutton() except ValueError: return QtGui.QMessageBox.warning( self, le2mtrans(u"Warning"), texts_PGGS.trans_PGGS(u"You must take a decision")) if not self._automatique: if QtGui.QMessageBox.question( self, le2mtrans(u"Confirmation"), le2mtrans(u"Do you confirm your choice"), QtGui.QMessageBox.No | QtGui.QMessageBox.Yes) != \ QtGui.QMessageBox.Yes: return logger.info(u"Send back {}".format(vote)) self.accept() self._defered.callback(vote)
class GuiDecision(QtGui.QDialog): def __init__(self, defered, automatique, parent, periode, historique): super(GuiDecision, self).__init__(parent) # variables self._defered = defered self._automatique = automatique self._historique = GuiHistorique(self, historique) layout = QtGui.QVBoxLayout(self) wperiod = WPeriod(period=periode, ecran_historique=self._historique, parent=self) layout.addWidget(wperiod) wexplanation = WExplication( text=texts_DP.get_text_explanation(), parent=self, size=(450, 80)) layout.addWidget(wexplanation) options = tuple([v for k, v in sorted(pms.OPTIONS.viewitems())]) self._wdecision = WRadio( texts=options, label=trans_DP(u"Choose an option"), parent=self, automatique=self._automatique) layout.addWidget(self._wdecision) buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) buttons.accepted.connect(self._accept) layout.addWidget(buttons) self.setWindowTitle(le2mtrans(u"Decision")) self.adjustSize() self.setFixedSize(self.size()) if self._automatique: self._timer_automatique = QtCore.QTimer() self._timer_automatique.timeout.connect( buttons.button(QtGui.QDialogButtonBox.Ok).click) self._timer_automatique.start(7000) def reject(self): pass def _accept(self): try: self._timer_automatique.stop() except AttributeError: pass try: decision = self._wdecision.get_checkedbutton() except ValueError: QtGui.QMessageBox.warning( self, le2mtrans(u"Warning"), trans_DP(u"You have to choose an option")) return if not self._automatique: confirmation = QtGui.QMessageBox.question( self, le2mtrans(u"Confirmation"), le2mtrans(u"Do you confirm your choice?"), QtGui.QMessageBox.No | QtGui.QMessageBox.Yes) if confirmation != QtGui.QMessageBox.Yes: return logger.info(u"Send back {}".format(decision)) self.accept() self._defered.callback(decision)
class GuiDecision(QtGui.QDialog): def __init__(self, defered, automatique, parent, periode, profil): """ :param defered: :param automatique: :param parent: :param periode: :param profil: only the table :return: """ super(GuiDecision, self).__init__(parent) # variables self._defered = defered self._automatique = automatique self._layout = QtGui.QVBoxLayout(self) # Explanation self._wexplanation = WExplication( text=texts_VM.get_text_explanation(periode, profil), parent=self, size=(450, 80)) self._layout.addWidget(self._wexplanation) # Politics self._wpolitics = WPolitics(self, profil, periode) self._layout.addWidget(self._wpolitics) # Vote votes = tuple([v for k, v in sorted(texts_VM.VOTES.viewitems())]) self._wvote = WRadio( label=texts_VM.trans_VM(u"You vote"), texts=votes, automatique=self._automatique, parent=self) self._layout.addWidget(self._wvote) # buttons self._buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) self._buttons.accepted.connect(self._accept) self._layout.addWidget(self._buttons) # title and size self.setWindowTitle(le2mtrans(u"Decision")) self.adjustSize() self.setFixedSize(self.size()) # automatic if self._automatique: self._timer_automatique = QtCore.QTimer() self._timer_automatique.timeout.connect( self._buttons.button(QtGui.QDialogButtonBox.Ok).click) self._timer_automatique.start(7000) def reject(self): pass def _accept(self): try: self._timer_automatique.stop() except AttributeError: pass try: decision = self._wvote.get_checkedbutton() except ValueError: return QtGui.QMessageBox.warning( self, le2mtrans(u"Warning"), texts_VM.trans_VM(u"You must vote")) if not self._automatique: confirmation = QtGui.QMessageBox.question( self, le2mtrans(u"Confirmation"), le2mtrans(u"Do you confirm your choice?"), QtGui.QMessageBox.No | QtGui.QMessageBox.Yes) if confirmation != QtGui.QMessageBox.Yes: return logger.info(u"Send back: {}".format(decision)) self.accept() self._defered.callback(decision)
class GuiDecision(QtGui.QDialog): def __init__(self, defered, automatique, parent, periode, historique): super(GuiDecision, self).__init__(parent) # variables self._defered = defered self._automatique = automatique self._historique = GuiHistorique(self, historique) layout = QtGui.QVBoxLayout(self) wperiod = WPeriod(period=periode, ecran_historique=self._historique, parent=self) layout.addWidget(wperiod) wexplanation = WExplication(text=texts_DP.get_text_explanation(), parent=self, size=(450, 80)) layout.addWidget(wexplanation) options = tuple([v for k, v in sorted(pms.OPTIONS.viewitems())]) self._wdecision = WRadio(texts=options, label=trans_DP(u"Choose an option"), parent=self, automatique=self._automatique) layout.addWidget(self._wdecision) buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) buttons.accepted.connect(self._accept) layout.addWidget(buttons) self.setWindowTitle(le2mtrans(u"Decision")) self.adjustSize() self.setFixedSize(self.size()) if self._automatique: self._timer_automatique = QtCore.QTimer() self._timer_automatique.timeout.connect( buttons.button(QtGui.QDialogButtonBox.Ok).click) self._timer_automatique.start(7000) def reject(self): pass def _accept(self): try: self._timer_automatique.stop() except AttributeError: pass try: decision = self._wdecision.get_checkedbutton() except ValueError: QtGui.QMessageBox.warning( self, le2mtrans(u"Warning"), trans_DP(u"You have to choose an option")) return if not self._automatique: confirmation = QtGui.QMessageBox.question( self, le2mtrans(u"Confirmation"), le2mtrans(u"Do you confirm your choice?"), QtGui.QMessageBox.No | QtGui.QMessageBox.Yes) if confirmation != QtGui.QMessageBox.Yes: return logger.info(u"Send back {}".format(decision)) self.accept() self._defered.callback(decision)