def __init__(self, automatique=False, parent=None, autotime=1000): super(WGains, self).__init__(parent) self.ui = OL_widgains.Ui_Form() self.ui.setupUi(self) self.ui.groupBox.setTitle(texts_OL.trans_OL(u"Payoffs")) options = [v.upper() for k, v in sorted(pms.OPTIONS.viewitems())] self.ui.label_x.setText(texts_OL.trans_OL(u"Option") + u" " + options[0]) self.ui.label_xvals.setText(u"{} pour vous et {} pour le joueur B".format( pms.CODES_PERIODES[pms.GAME][0][0], pms.CODES_PERIODES[pms.GAME][0][1] )) self.ui.label_y.setText(texts_OL.trans_OL(u"Option") + u" " + options[1]) self.ui.label_yvals.setText(u"{} pour vous et {} pour le joueur B".format( pms.CODES_PERIODES[pms.GAME][1][0], pms.CODES_PERIODES[pms.GAME][1][1] )) self.ui.pushButton_ok.setText(u"Ok") self.ui.pushButton_ok.clicked.connect( lambda _: self.ui.pushButton_ok.setEnabled(False)) if automatique: self._timer = QtCore.QTimer() self._timer.setSingleShot(True) self._timer.timeout.connect(self.ui.pushButton_ok.click) self._timer.start(autotime)
def __init__(self, parent): super(DConfiguration, self).__init__(parent) layout = QtGui.QVBoxLayout(self) treats = [v.upper() for k, v in sorted(pms.TREATMENTS.viewitems())] self._widtreat = WCombo( label=texts_OL.trans_OL(u"Treatment"), items=treats, parent=self) layout.addWidget(self._widtreat) self._widgame = WCombo( label=texts_OL.trans_OL(u"Select the game"), items=map(str, sorted(pms.CODES_PERIODES.viewkeys())), parent=self) self._widgame.ui.comboBox.setCurrentIndex(pms.GAME - 1) layout.addWidget(self._widgame) buttons = QtGui.QDialogButtonBox( QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok, QtCore.Qt.Horizontal, self) buttons.accepted.connect(self._accept) buttons.rejected.connect(self.reject) layout.addWidget(buttons) self.setWindowTitle(le2mtrans(u"Configure")) self.adjustSize() self.setFixedSize(self.size())
def __init__(self, le2mserv): self._le2mserv = le2mserv # creation of the menu (will be placed in the "part" menu on the # server screen) actions = OrderedDict() actions[le2mtrans(u"Configure")] = self._configure actions[le2mtrans(u"Display parameters")] = \ lambda _: self._le2mserv.gestionnaire_graphique. \ display_information2( utiltools.get_module_info(pms), le2mtrans(u"Parameters")) actions[texts_OL.trans_OL(u"Set roles")] = self._set_roles actions[le2mtrans(u"Start")] = lambda _: self._demarrer() actions[texts_OL.trans_OL(u"Display additional questions")] = \ lambda _: self._display_additionalquestion() actions[le2mtrans(u"Display payoffs")] = \ lambda _: self._le2mserv.gestionnaire_experience.\ display_payoffs_onserver("oathAndLies") self._le2mserv.gestionnaire_graphique.add_topartmenu( u"Oath and Lies", actions) # final questionnaire self._le2mserv.gestionnaire_graphique.screen.action_finalquest. \ triggered.disconnect() self._le2mserv.gestionnaire_graphique.screen.action_finalquest. \ triggered.connect(lambda _: self._display_questfinal())
def __init__(self, parent): super(WChoiceB, self).__init__(parent) self.ui = OL_widChoiceB.Ui_Form() self.ui.setupUi(self) self.ui.groupBox.setTitle(texts_OL.trans_OL(u"Choice of a number")) self.ui.label.setText(texts_OL.trans_OL( u"Enter a number between 1 and 6")) self.ui.spinBox.setMinimum(0) self.ui.spinBox.setMaximum(6) self.ui.spinBox.setSingleStep(1) self.ui.spinBox.setButtonSymbols(QtGui.QSpinBox.NoButtons) self.ui.spinBox.setValue(0)
def _display_additionalquestion(self): if not hasattr(self, "_tous"): self._le2mserv.gestionnaire_graphique.display_warning( texts_OL.trans_OL(u"You must start the part before to run " u"the questionnaire")) return if not self._le2mserv.gestionnaire_graphique.question( texts_OL.trans_OL(u"Do you want to start additional questions?")): return self._le2mserv.gestionnaire_graphique.infoclt(None) yield (self._le2mserv.gestionnaire_experience.run_step( texts_OL.trans_OL(u"Additional questions"), self._tous, "display_additionalquestion"))
def _display_additionalquestion(self): if not hasattr(self, "_tous"): self._le2mserv.gestionnaire_graphique.display_warning( texts_OL.trans_OL(u"You must start the part before to run " u"the questionnaire")) return if not self._le2mserv.gestionnaire_graphique.question( texts_OL.trans_OL( u"Do you want to start additional questions?")): return self._le2mserv.gestionnaire_graphique.infoclt(None) yield (self._le2mserv.gestionnaire_experience.run_step( texts_OL.trans_OL(u"Additional questions"), self._tous, "display_additionalquestion"))
def __init__(self, parent, automatique, autotime=1000): super(WChoiceMsg, self).__init__(parent) self._automatique = automatique self._autotime = autotime self.ui = OL_widChoiceMsg.Ui_Form() self.ui.setupUi(self) self.ui.groupBox.setTitle(texts_OL.trans_OL(u"Message to B")) self.ui.label.setText(texts_OL.trans_OL( u"Select the message you sent to player B")) self._msg = [le2mtrans(u"Choose")] self._msg.extend([texts_OL.trans_OL( u"The outcome of the dice toss is") + u" {}".format(i) for i in range(1, 7)]) self.ui.comboBox.addItems(self._msg)
def __init__(self, parent, automatique, autotime=1000): super(WChoiceB, self).__init__(parent) self._automatique = automatique self._autotime = autotime self.ui = OL_widChoiceB.Ui_Form() self.ui.setupUi(self) self.ui.groupBox.setTitle(texts_OL.trans_OL(u"Choice of a number")) self.ui.label.setText(texts_OL.trans_OL( u"Enter a number between 1 and 6")) self.ui.spinBox.setMinimum(0) self.ui.spinBox.setMaximum(6) self.ui.spinBox.setSingleStep(1) self.ui.spinBox.setButtonSymbols(QtGui.QSpinBox.NoButtons) self.ui.spinBox.setValue(0)
def _accept(self): self._players_A = [j for j in self._players if u"{} / {}".format(j.hostname, j) in self._drag.get_rightitems()] logger.info("A: {}".format(self._players_A)) if self._players_A: confirm = QtGui.QMessageBox.question( self, texts_OL.trans_OL(u"Players A"), texts_OL.trans_OL(u"There are {} players A:\n").format( len(self._players_A)) + u"{}".format([u"{} / {}".format(p.hostname, p) for p in self._players_A]) + u"\n" + texts_OL.trans_OL(u"Do you confirm?"), QtGui.QMessageBox.No | QtGui.QMessageBox.Yes ) if confirm != QtGui.QMessageBox.Yes: return self.accept()
def __init__(self, automatique=False, parent=None, autotime=1000): super(WGains, self).__init__(parent) self.ui = OL_widgains.Ui_Form() self.ui.setupUi(self) self.ui.groupBox.setTitle(texts_OL.trans_OL(u"Payoffs")) options = [v.upper() for k, v in sorted(pms.OPTIONS.viewitems())] self.ui.label_x.setText(texts_OL.trans_OL(u"Option") + u" " + options[0]) self.ui.label_y.setText(texts_OL.trans_OL(u"Option") + u" " + options[1]) self.ui.pushButton_ok.setText(u"Ok") self.ui.pushButton_ok.clicked.connect( lambda _: self.ui.pushButton_ok.setEnabled(False)) if automatique: self._timer = QtCore.QTimer() self._timer.setSingleShot(True) self._timer.timeout.connect(self.ui.pushButton_ok.click) self._timer.start(autotime)
def __init__(self, parent, automatique, autotime=1000): super(WDiceToss, self).__init__(parent) self._automatique = automatique self._autotime = autotime self.ui = OL_widDicetoss.Ui_Form() self.ui.setupUi(self) self.ui.groupBox.setTitle(texts_OL.trans_OL(u"Dice toss")) self.ui.pushButton.setText(texts_OL.trans_OL(u"Toss the dice")) self.ui.pushButton.clicked.connect(self._click) self.ui.label.setText(texts_OL.trans_OL( u"The outcome of the dice toss is")) self.ui.spinBox.setReadOnly(True) self.ui.spinBox.setButtonSymbols(QtGui.QSpinBox.NoButtons) self.ui.spinBox.setMinimum(0) self.ui.spinBox.setMaximum(6) self.ui.spinBox.setSingleStep(1) self.ui.spinBox.setValue(0)
def __init__(self, parent, automatique, val_de, autotime=1000): super(WMsgA, self).__init__(parent) self.ui = OL_widMsgA.Ui_Form() self.ui.setupUi(self) self.ui.groupBox.setTitle(texts_OL.trans_OL(u"Message from A")) self.ui.label_explanation.setText(texts_OL.trans_OL( u"Player A sends you the message") + u": ") self.ui.label_message.setText(u"<em>" + texts_OL.trans_OL( u"the outcome of the dice toss is") + u" {}</em>".format(val_de)) self.ui.pushButton.setText(u"Ok") self.ui.pushButton.clicked.connect( lambda _: self.ui.pushButton.setEnabled(False)) if automatique: self._timer = QtCore.QTimer() self._timer.setSingleShot(True) self._timer.timeout.connect(self.ui.pushButton.click) self._timer.start(autotime)
def _display_questfinal(self): if not self._le2mserv.gestionnaire_base.is_created(): self._le2mserv.gestionnaire_graphique.display_warning( le2mtrans(u"There is no database yet. You first need to " u"load at least one part.")) return if not hasattr(self, "_tous"): self._le2mserv.gestionnaire_graphique.display_warning( texts_OL.trans_OL(u"You must play the part before to " u"start the questionnaire")) return if not self._le2mserv.gestionnaire_graphique.question( le2mtrans(u"Start the final questionnaire?")): return yield (self._le2mserv.gestionnaire_experience.run_step( le2mtrans(u"Final questionnaire"), self._tous, "display_questfinal"))
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)
def get_value(self): if self.ui.spinBox.value() == 0: raise ValueError(texts_OL.trans_OL( u"You must enter a number between 1 and 6")) return self.ui.spinBox.value()
def get_currentindex(self): if self.ui.comboBox.currentIndex() == 0: raise ValueError(texts_OL.trans_OL(u"You must choose a message")) return self.ui.comboBox.currentIndex()