class DSequenceChoice(QtGui.QDialog):
    def __init__(self, nb_played_seq, parent):
        super(DSequenceChoice, self).__init__(parent)

        layout = QtGui.QVBoxLayout(self)

        self._choice = WSpinbox(
            minimum=1,
            maximum=nb_played_seq,
            automatique=False,
            parent=self,
            label=texts_PGGS.trans_PGGS(u"Choose the sequence to display"))
        layout.addWidget(self._choice)

        buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Cancel
                                         | QtGui.QDialogButtonBox.Ok)
        buttons.accepted.connect(self.accept)
        buttons.rejected.connect(self.reject)
        layout.addWidget(buttons)

        self.setWindowTitle(le2mtrans(u"Sequence choice"))
        self.adjustSize()
        self.setFixedSize(self.size())

    def get_choice(self):
        return self._choice.get_value()
class GuiDecision(QtGui.QDialog):
    def __init__(self, defered, automatique, parent, periode, historique):
        super(GuiDecision, self).__init__(parent)

        self._defered = defered
        self._automatique = automatique
        self._historique = GuiHistorique(self, historique)

        layout = QtGui.QVBoxLayout(self)

        self._widperiod = WPeriod(period=periode, ecran_historique=self._historique, parent=self)
        layout.addWidget(self._widperiod)

        self._widexplication = WExplication(text=texts_CPR.DECISION_explication, parent=self)
        layout.addWidget(self._widexplication)

        self._widdecision = WSpinbox(
            label=texts_CPR.DECISION_label,
            minimum=pms.DECISION_MIN,
            maximum=pms.DECISION_MAX,
            interval=pms.DECISION_STEP,
            automatique=self._automatique,
            parent=self,
        )
        layout.addWidget(self._widdecision)

        buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok)
        buttons.accepted.connect(self._accept)
        layout.addWidget(buttons)

        if self._automatique:
            self._timer_automatique = QtCore.QTimer()
            self._timer_automatique.timeout.connect(buttons.button(QtGui.QDialogButtonBox.Ok).click)
            self._timer_automatique.start(7000)

        # title and size
        self.setWindowTitle(texts_CPR.DECISION_titre)
        self.adjustSize()
        self.setFixedSize(self.size())

    def reject(self):
        pass

    def _accept(self):
        try:
            self._timer_automatique.stop()
        except AttributeError:
            pass
        decision = self._widdecision.get_value()
        if not self._automatique:
            confirmation = QtGui.QMessageBox.question(
                self,
                texts_CPR.DECISION_confirmation.titre,
                texts_CPR.DECISION_confirmation.message,
                QtGui.QMessageBox.No | QtGui.QMessageBox.Yes,
            )
            if confirmation != QtGui.QMessageBox.Yes:
                return
        self.accept()
        self._defered.callback(decision)
Example #3
0
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=textes_PGG.get_text_explanation(),
            parent=self, size=(450, 80))
        layout.addWidget(wexplanation)

        self._wdecision = WSpinbox(
            label=textes_PGG.get_text_label_decision(),
            minimum=pms.DECISION_MIN, maximum=pms.DECISION_MAX,
            interval=pms.DECISION_STEP, automatique=self._automatique,
            parent=self)
        layout.addWidget(self._wdecision)

        buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok)
        buttons.accepted.connect(self._accept)
        layout.addWidget(buttons)

        self.setWindowTitle(trans_PGG(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
        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
        decision = self._wdecision.get_value()
        logger.info(u"Decision callback {}".format(decision))
        self.accept()
        self._defered.callback(decision)
Example #4
0
class GuiDecision(QtGui.QDialog):
    def __init__(self, defered, automatique, parent, periode, historique):
        super(GuiDecision, self).__init__(parent)

        self._defered = defered
        self._automatique = automatique

        layout = QtGui.QVBoxLayout(self)

        self._widexplication = WExplication(
            text=texts_GP.get_text_explanation(), size=(500, 70), parent=self)
        layout.addWidget(self._widexplication)

        self._widdecision = WSpinbox(label=trans_GP(
            u"Choose the amount you want to invest in the "
            u"risky option"),
                                     minimum=pms.DECISION_MIN,
                                     maximum=pms.DECISION_MAX,
                                     interval=pms.DECISION_STEP,
                                     parent=self,
                                     automatique=self._automatique)
        layout.addWidget(self._widdecision)

        # bouton box
        buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok,
                                         QtCore.Qt.Horizontal, self)
        buttons.accepted.connect(self._accept)
        layout.addWidget(buttons)

        if self._automatique:
            self._timer_automatique = QtCore.QTimer()
            self._timer_automatique.timeout.connect(
                buttons.button(QtGui.QDialogButtonBox.Ok).click)
            self._timer_automatique.start(7000)

        # title and size
        self.setWindowTitle(le2mtrans(u"Decision"))
        self.adjustSize()
        self.setFixedSize(self.size())

    def reject(self):
        pass

    def _accept(self):
        try:
            self._timer_automatique.stop()
        except AttributeError:
            pass
        decision = self._widdecision.get_value()
        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)
Example #5
0
class GuiDecision(QtGui.QDialog):
    def __init__(self, defered, automatique, parent, periode, historique):
        super(GuiDecision, self).__init__(parent)

        # variables
        self._defered = defered
        self._automatique = automatique

        layout = QtGui.QVBoxLayout(self)

        self._widexplication = WExplication(text=textes.DECISION_explication,
                                            parent=self,
                                            size=(520, 60))
        layout.addWidget(self._widexplication)

        self._widdecision = WSpinbox(label=textes.DECISION_label,
                                     minimum=pms.DECISION_MIN,
                                     maximum=pms.DECISION_MAX,
                                     parent=self,
                                     automatique=self._automatique)
        layout.addWidget(self._widdecision)

        buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok,
                                         QtCore.Qt.Horizontal, self)
        buttons.accepted.connect(self._accept)
        layout.addWidget(buttons)

        # title and size
        self.setWindowTitle(textes.DECISION_titre)
        self.adjustSize()
        self.setFixedSize(self.size())

        # automatic
        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
        decision = self._widdecision.get_value()
        if not self._automatique:
            confirmation = QtGui.QMessageBox.question(
                self, textes.DECISION_confirmation.titre,
                textes.DECISION_confirmation.message,
                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)
Example #6
0
class GuiDecision(QtGui.QDialog):
    def __init__(self, defered, automatique, parent, periode, historique):
        super(GuiDecision, self).__init__(parent)

        self._defered = defered
        self._automatique = automatique
        self._historique = GuiHistorique(self, historique)

        layout = QtGui.QVBoxLayout(self)

        self._widperiod = WPeriod(
            period=periode, ecran_historique=self._historique, parent=self)
        layout.addWidget(self._widperiod)

        self._widexplication = WExplication(
            text=texts_CPR.DECISION_explication, parent=self)
        layout.addWidget(self._widexplication)

        self._widdecision = WSpinbox(
            label=texts_CPR.DECISION_label, minimum=pms.DECISION_MIN,
            maximum=pms.DECISION_MAX, interval=pms.DECISION_STEP,
            automatique=self._automatique, parent=self)
        layout.addWidget(self._widdecision)

        buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok)
        buttons.accepted.connect(self._accept)
        layout.addWidget(buttons)

        if self._automatique:
            self._timer_automatique = QtCore.QTimer()
            self._timer_automatique.timeout.connect(
                buttons.button(QtGui.QDialogButtonBox.Ok).click)
            self._timer_automatique.start(7000)

        # title and size
        self.setWindowTitle(texts_CPR.DECISION_titre)
        self.adjustSize()
        self.setFixedSize(self.size())

    def reject(self):
        pass
    
    def _accept(self):
        try:
            self._timer_automatique.stop()
        except AttributeError:
            pass
        decision = self._widdecision.get_value()
        if not self._automatique:
            confirmation = QtGui.QMessageBox.question(
                self, texts_CPR.DECISION_confirmation.titre,
                texts_CPR.DECISION_confirmation.message,
                QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)
            if confirmation != QtGui.QMessageBox.Yes: 
                return
        self.accept()
        self._defered.callback(decision)
Example #7
0
class GuiDecision(QtGui.QDialog):
    def __init__(self, defered, automatique, parent, periode, historique):
        super(GuiDecision, self).__init__(parent)

        self._defered = defered
        self._automatique = automatique

        layout = QtGui.QVBoxLayout(self)

        self._widexplication = WExplication(
            text=texts_GP.get_text_explanation(), size=(500, 70), parent=self)
        layout.addWidget(self._widexplication)

        self._widdecision = WSpinbox(
            label=trans_GP(u"Choose the amount you want to invest in the "
                           u"risky option"),
            minimum=pms.DECISION_MIN, maximum=pms.DECISION_MAX,
            interval=pms.DECISION_STEP, parent=self,
            automatique=self._automatique)
        layout.addWidget(self._widdecision)

        # bouton box
        buttons = QtGui.QDialogButtonBox(
            QtGui.QDialogButtonBox.Ok, QtCore.Qt.Horizontal, self)
        buttons.accepted.connect(self._accept)
        layout.addWidget(buttons)

        if self._automatique:
            self._timer_automatique = QtCore.QTimer()
            self._timer_automatique.timeout.connect(
                buttons.button(QtGui.QDialogButtonBox.Ok).click)
            self._timer_automatique.start(7000)

        # title and size
        self.setWindowTitle(le2mtrans(u"Decision"))
        self.adjustSize()
        self.setFixedSize(self.size())

    def reject(self):
        pass
    
    def _accept(self):
        try:
            self._timer_automatique.stop()
        except AttributeError:
            pass
        decision = self._widdecision.get_value()
        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)
Example #8
0
class GuiDecision(QtGui.QDialog):
    def __init__(self, defered, automatique, parent, periode, historique):
        super(GuiDecision, self).__init__(parent)

        # variables
        self._defered = defered
        self._automatique = automatique

        layout = QtGui.QVBoxLayout(self)

        self._widexplication = WExplication(
            text=textes.DECISION_explication, parent=self, size=(520, 60))
        layout.addWidget(self._widexplication)

        self._widdecision = WSpinbox(
            label=textes.DECISION_label, minimum=pms.DECISION_MIN,
            maximum=pms.DECISION_MAX, parent=self,
            automatique=self._automatique)
        layout.addWidget(self._widdecision)

        buttons = QtGui.QDialogButtonBox(
            QtGui.QDialogButtonBox.Ok, QtCore.Qt.Horizontal, self)
        buttons.accepted.connect(self._accept)
        layout.addWidget(buttons)

        # title and size
        self.setWindowTitle(textes.DECISION_titre)
        self.adjustSize()
        self.setFixedSize(self.size())

        # automatic
        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
        decision = self._widdecision.get_value()
        if not self._automatique:
            confirmation = QtGui.QMessageBox.question(
                self, textes.DECISION_confirmation.titre,
                textes.DECISION_confirmation.message,
                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 DExpectation(QtGui.QDialog):
    def __init__(self, defered, automatique, parent, text, expec_before=None):
        QtGui.QDialog.__init__(self, parent)

        self._defered = defered
        self._automatique = automatique

        layout = QtGui.QVBoxLayout()
        self.setLayout(layout)

        explanation = WExplication(text=text[0])
        layout.addWidget(explanation)

        self._spin_expectation = WSpinbox(parent=self,
                                          minimum=pms.DECISION_MIN,
                                          maximum=pms.DECISION_MAX,
                                          interval=pms.DECISION_STEP,
                                          label=text[1],
                                          automatique=self._automatique)
        if expec_before is not None:
            self._spin_expectation.spinBox.setValue(expec_before)
        layout.addWidget(self._spin_expectation)

        button = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok)
        button.accepted.connect(self._accept)
        layout.addWidget(button)

        self.setWindowTitle(trans_PGGS(u"Expectation"))
        self.adjustSize()
        self.setFixedSize(self.size())

        if self._automatique:
            self._timer = QtCore.QTimer()
            self._timer.timeout.connect(self._accept)
            self._timer.start(7000)

    def reject(self):
        pass

    def _accept(self):
        try:
            self._timer.stop()
        except AttributeError:
            pass
        expectation = self._spin_expectation.get_value()
        if not self._automatique:
            confirm = QtGui.QMessageBox.question(
                self, u"Confirmation",
                le2mtrans(u"Do you confirm your choice?"),
                QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)
            if confirm != QtGui.QMessageBox.Yes:
                return
        logger.info(le2mtrans(u"Send back {}".format(expectation)))
        self.accept()
        self._defered.callback(expectation)
class DQuestionDictator(QtGui.QDialog):
    def __init__(self, defered, automatique, parent):
        super(DQuestionDictator, self).__init__(parent)

        self._defered = defered
        self._automatique = automatique

        layout = QtGui.QVBoxLayout(self)

        self._widPrediction = WSpinbox(
            label=texts_TC.get_text_predictiondictator(), minimum=0, maximum=10,
            automatique=self._automatique, parent=self)
        layout.addWidget(self._widPrediction)

        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"Prediction"))
        self.adjustSize()
        self.setFixedSize(self.size())

    def reject(self):
        pass

    def _accept(self):
        try:
            self._timer.stop()
        except AttributeError:
            pass

        if not self._automatique:
            confirm = QtGui.QMessageBox.question(
                self, u"Confirmation", trans_TC(u"Do you confirm your choice?"),
                QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)
            if confirm != QtGui.QMessageBox.Yes:
                return
        dec = self._widPrediction.get_value()
        logger.info(u"Send back {}".format(dec))
        self._defered.callback(dec)
        self.accept()
class DSequenceChoice(QtGui.QDialog):
    def __init__(self, nb_played_seq, parent):
        super(DSequenceChoice, self).__init__(parent)

        layout = QtGui.QVBoxLayout(self)

        self._choice = WSpinbox(
            minimum=1, maximum=nb_played_seq, automatique=False, parent=self,
            label=texts_PGGS.trans_PGGS(u"Choose the sequence to display"))
        layout.addWidget(self._choice)

        buttons = QtGui.QDialogButtonBox(
            QtGui.QDialogButtonBox.Cancel |QtGui.QDialogButtonBox.Ok)
        buttons.accepted.connect(self.accept)
        buttons.rejected.connect(self.reject)
        layout.addWidget(buttons)

        self.setWindowTitle(le2mtrans(u"Sequence choice"))
        self.adjustSize()
        self.setFixedSize(self.size())

    def get_choice(self):
        return self._choice.get_value()
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)
class DDecision(QtGui.QDialog):
    def __init__(self, defered, automatique, parent, historique, period):
        QtGui.QDialog.__init__(self, parent)

        self._defered = defered
        self._automatique = automatique
        self._historique = GuiHistorique(self, historique, size=(700, 500))

        layout = QtGui.QVBoxLayout(self)

        wperiod = WPeriod(period=period, ecran_historique=self._historique,
                          parent=self)
        layout.addWidget(wperiod)

        wexplanation = WExplication(
            text=txt.get_expl_decision(), parent=self, size=(500, 60))
        layout.addWidget(wexplanation)

        self._wdecision = WSpinbox(label=txt.get_lab_decision(), minimum=pms.MIN,
                             maximum=pms.MAX, interval=pms.STEP, 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_value()
        except ValueError as e:
            return QtGui.QMessageBox.warning(
                self, le2mtrans(u"Warning"), e.message)

        if not self._automatique:
            if not 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(decision))
        self.accept()
        self._defered.callback(decision)
class GuiDecision(QtGui.QDialog):
    def __init__(self, defered, automatique, parent, periode, historique,
                 sinistred):
        super(GuiDecision, self).__init__(parent)

        # variables
        self._defered = defered
        self._automatique = automatique
        self._historique = GuiHistorique(self, historique, size=(700, 500))
        self._sinistred = sinistred

        layout = QtGui.QVBoxLayout(self)

        # period and history button
        wperiod = WPeriod(period=periode, ecran_historique=self._historique,
                          parent=self)
        layout.addWidget(wperiod)

        wexplanation = WExplication(
            text=texts_PGGS.get_text_explanation(), parent=self, size=(500, 60))
        layout.addWidget(wexplanation)

        max = 0 if self._sinistred else pms.DECISION_MAX
        self._wcontrib = WSpinbox(
            minimum=0, maximum=max, automatique=self._automatique, parent=self,
            label=texts_PGGS.trans_PGGS(u"How much do you invest in "
                                        u"the public account?"))
        layout.addWidget(self._wcontrib)

        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._wcontrib.get_value()
        except ValueError as e:
            return QtGui.QMessageBox.warning(
                self, le2mtrans(u"Warning"), e.message)

        if not self._automatique:
            if not self._sinistred:
                if not 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(decision))
        self.accept()
        self._defered.callback(decision)
class GuiDecision(QtGui.QDialog):
    def __init__(self, defered, automatique, parent, periode, historique,
                 max_decision):
        super(GuiDecision, self).__init__(parent)

        # variables
        self._defered = defered
        self._automatique = automatique
        self._historique = GuiHistorique(self,
                                         historique,
                                         size=(HISTO_WIDTH, 500))
        self._max_decision = max_decision

        layout = QtGui.QVBoxLayout(self)

        # period and history button
        wperiod = WPeriod(period=periode,
                          ecran_historique=self._historique,
                          parent=self)
        layout.addWidget(wperiod)

        wexplanation = WExplication(text=texts_PGGS.get_text_explanation(),
                                    parent=self,
                                    size=(500, 60))
        layout.addWidget(wexplanation)

        self._wcontrib = WSpinbox(minimum=0,
                                  maximum=self._max_decision,
                                  automatique=self._automatique,
                                  parent=self,
                                  label=trans_PGGS(
                                      u"How much do you invest in "
                                      u"the public account?"))
        layout.addWidget(self._wcontrib)

        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._wcontrib.get_value()
        except ValueError as e:
            return QtGui.QMessageBox.warning(self, le2mtrans(u"Warning"),
                                             e.message)

        if not self._automatique:
            if self._max_decision > 0:
                if not 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(decision))
        self.accept()
        self._defered.callback(decision)
Example #16
0
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=textes_PGG.get_text_explanation(),
                                    parent=self,
                                    size=(450, 80))
        layout.addWidget(wexplanation)

        self._wdecision = WSpinbox(label=textes_PGG.get_text_label_decision(),
                                   minimum=pms.DECISION_MIN,
                                   maximum=pms.DECISION_MAX,
                                   interval=pms.DECISION_STEP,
                                   automatique=self._automatique,
                                   parent=self)
        layout.addWidget(self._wdecision)

        buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok)
        buttons.accepted.connect(self._accept)
        layout.addWidget(buttons)

        self.setWindowTitle(trans_PGG(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
        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
        decision = self._wdecision.get_value()
        logger.info(u"Decision callback {}".format(decision))
        self.accept()
        self._defered.callback(decision)