Example #1
0
    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[le2mtrans(u"Start")] = lambda _: self._demarrer()
        # actions[trans_PGGS(u"Display expectations")] = \
        #     lambda _: self._display_expectations()
        actions[le2mtrans(u"Display payoffs")] = self._display_payoffs

        self._le2mserv.gestionnaire_graphique.add_topartmenu(
            u"Public Good Game Solidarity", actions)

        # final question
        self._le2mserv.gestionnaire_graphique.screen.action_finalquest.\
            triggered.disconnect()
        self._le2mserv.gestionnaire_graphique.screen.action_finalquest.\
            triggered.connect(lambda _: self._display_questfinal())

        self._currentsequence = 0
Example #2
0
    def _display_questfinal(self):
        if not self._le2mserv.gestionnaire_base.is_created():
            QtGui.QMessageBox.warning(
                self._le2mserv.gestionnaire_graphique.screen,
                le2mtrans(u"Warning"),
                le2mtrans(u"There is no database yet. You first need to "
                          u"load at least one part."))
            return
        if not hasattr(self, "_tous"):
            QtGui.QMessageBox.warning(
                self._le2mserv.gestionnaire_graphique.screen,
                le2mtrans(u"Warning"),
                trans_PGGS(u"PGGS has to be run before to "
                         u"start this questionnaire"))
            return

        confirmation = QtGui.QMessageBox.question(
            self._le2mserv.gestionnaire_graphique.screen,
            le2mtrans(u"Confirmation"),
            le2mtrans(u"Start the final questionnaire?"),
            QtGui.QMessageBox.Cancel | QtGui.QMessageBox.Ok)
        if confirmation != QtGui.QMessageBox.Ok:
            return

        yield (self._le2mserv.gestionnaire_experience.run_step(
            trans_PGGS(u"Final questionnaire"), self._tous,
            "display_questfinal"))
Example #3
0
    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())
Example #4
0
    def _accept(self):
        try:
            self._timer_automatique.stop()
        except AttributeError:
            pass
        inputs = self._get_inputs()
        if type(inputs) is dict:

            try:

                inputs["naissance_ville"] = self._naissance_ville.get_text()

            except ValueError:
                return QtGui.QMessageBox.warning(
                    self, le2mtrans(u"Warning"),
                    le2mtrans(u"You must answer to all the questions"))

            if not self._automatique:
                if QtGui.QMessageBox.question(
                    self, le2mtrans(u"Confirmation"),
                    le2mtrans(u"Do you confirm your answers?"),
                    QtGui.QMessageBox.No | QtGui.QMessageBox.Yes) != \
                        QtGui.QMessageBox.Yes: return

            logger.info(u"Send back: {}".format(inputs))
            self.accept()
            self._defered.callback(inputs)

        else:
            return
Example #5
0
 def _headtail(self):
     screen = DHeadtail(self)
     if screen.exec_():
         self._le2mserv.gestionnaire_graphique.infoserv(
             le2mtrans(u"Head and tail: {}".format(
                 le2mtrans(u"Head") if screen.get_value() == FACE else
                 le2mtrans(u"Tail"))))
Example #6
0
 def _accept(self):
     if self._widrandint.ui.pushButton_start.isEnabled():
         QtGui.QMessageBox.warning(
             self, le2mtrans(u"Warning"),
             le2mtrans(u"You must drawn a random number"))
         return
     self.accept()
Example #7
0
 def _print(self):
     """
     Print the table with the subjects' payoffs
     """
     if not self._payoffs:
         return
     html = u"<table align='center' border=1>\n<tr>" \
            u"<td align='center'><b>"
     html += le2mtrans(u"Hostname")
     html += u"</b></td>" \
             u"<td align='center'><b>"
     html += le2mtrans(u"Payoff")
     html += u"</b></td></tr>\n"
     for l in self._payoffs:
         html += u"<tr><td align='center'>{}</>" \
                 u"<td align='center'>{}&euro;</td>" \
                 u"</tr>\n".format(l[0], l[1])
     html += u"</table>\n"
     doc = QtGui.QTextDocument()
     doc.setHtml(html)
     printer = QtGui.QPrinter()
     dialog = QtGui.QPrintDialog(printer)
     dialog.setModal(True)
     dialog.setWindowTitle(le2mtrans(u"Payoffs"))
     if dialog.exec_():
         doc.print_(printer)
Example #8
0
 def _accept(self):
     if self._widdice.ui.pushButton_start.isEnabled():
         QtGui.QMessageBox.warning(
             self, le2mtrans(u"Warning"),
             le2mtrans(u"You must roll the dice"))
         return
     self.accept()
Example #9
0
    def __init__(self, liste_joueurs, parent=None):
        super(GuiGenres, self).__init__(parent)

        # variables
        self._liste_joueurs = liste_joueurs

        # création gui
        self.ui = servguigenders.Ui_Dialog()
        self.ui.setupUi(self)

        # explication
        self.ui.textEdit_explication.setFixedSize(350, 30)
        self.ui.textEdit_explication.setText(
            le2mtrans(u"Please check the men and let the women unchecked."))

        # listView
        self.ui.listView.setFixedSize(350, 350)
        self._model = QtGui.QStandardItemModel()
        for j in self._liste_joueurs:
            item = QtGui.QStandardItem(str(j))
            item.setCheckState(QtCore.Qt.Unchecked)
            item.setCheckable(True)
            item.setEditable(False)
            self._model.appendRow(item)
        self.ui.listView.setModel(self._model)

        self.ui.buttonBox.accepted.connect(self._accept)
        self.ui.buttonBox.rejected.connect(self.reject)
        self.setWindowTitle(le2mtrans(u"Set subjects' gender"))
        self.setFixedSize(400, 550)
Example #10
0
    def __init__(self, le2mserv, partname, payoffs):
        super(GuiPayoffs, self).__init__()
        self._le2mserv = le2mserv
        self._partname = partname
        self._payoffs = payoffs

        # creation gui
        self.ui = servguipayoffs.Ui_Dialog()
        self.ui.setupUi(self)

        # table model for displaying payoffs
        self._tableModel = TableModelPaiements(self._payoffs)
        self.ui.tableView.setModel(self._tableModel)
        self.ui.tableView.horizontalHeader().setResizeMode(
            QtGui.QHeaderView.Stretch)

        # slot
        self.ui.pushButton_imprimer.clicked.connect(self._print)
        self.ui.pushButton_enregistrer.clicked.connect(self._save)
        self.ui.pushButton_afficher.clicked.connect(self._display_onremotes)
        self.ui.pushButton_ajouter.clicked.connect(self._addto_finalpayoffs)

        if self._partname == "base":
            self.setWindowTitle(le2mtrans(u"Payoffs for the experiment"))
            self.ui.pushButton_ajouter.setEnabled(False)
        else:
            self.setWindowTitle(le2mtrans(u"Payoffs of part {}").format(
                self._partname))
        self.setFixedSize(550, 608)
    def _demarrer(self):
        """
        Start the part
        :return:
        """
        # check conditions =====================================================
        if not self.le2msrv.gestionnaire_graphique.question(
                le2mtrans(u"Start") + u" partagevolontairequestionnaire?"):
            return

        # init part ============================================================
        yield (self.le2msrv.gestionnaire_experience.init_part(
            "partagevolontairequestionnaire", "PartiePVQ", "RemotePVQ", pms))
        self._tous = self.le2msrv.gestionnaire_joueurs.get_players(
            'partagevolontairequestionnaire')

        # set parameters on remotes
        yield (self.le2msrv.gestionnaire_experience.run_step(
            le2mtrans(u"Configure"), self._tous, "configure"))

        # Start part ===========================================================
        # init period
        yield (self.le2msrv.gestionnaire_experience.run_func(
            self._tous, "newperiod", 0))

        # decision
        yield (self.le2msrv.gestionnaire_experience.run_step(
            le2mtrans(u"Decision"), self._tous, "display_decision"))

        # End of part ==========================================================
        yield (self.le2msrv.gestionnaire_experience.finalize_part(
            "partagevolontairequestionnaire"))
Example #12
0
 def remove_wait_mode(self, list_players):
     """
     Change the icon color to green, meaning that the remote has taken
     his decision
     :param list_players: either a list of players (or parts) or only one
      element (player or part)
     """
     if isinstance(list_players, list):
         for p in list_players:
             try:
                 index = self._players_wait_mode.index(p)
             except ValueError as e: 
                 logger.warning(
                     le2mtrans(u"Problem with remove_waitmode: "
                               u"{msg}").format(e.message)
                 )
             else:
                 self.ui.listWidget_attente.item(index).setIcon(
                     self._icon_vert)
     else:
         try:
             index = self._players_wait_mode.index(list_players)
         except ValueError as e: 
             logger.warning(
                 le2mtrans(u"Problem with remove_waitmode: "
                           u"{msg}").format(e.message)
             )
         else:
             self.ui.listWidget_attente.item(index).setIcon(self._icon_vert)
Example #13
0
    def _accept(self):
        try:
            self._timer_automatique.stop()
        except AttributeError:
            pass
        inputs = self._get_inputs()
        if type(inputs) is dict:

            try:
                inputs["naissance_ville"] = self._naissance_ville.get_text()
            except ValueError:
                return QtGui.QMessageBox.warning(
                    self, le2mtrans(u"Warning"),
                    le2mtrans(u"You must answer to all the questions"))

            if not self._automatique:
                if QtGui.QMessageBox.question(
                    self, le2mtrans(u"Confirmation"),
                    le2mtrans(u"Do you confirm your answers?"),
                    QtGui.QMessageBox.No | QtGui.QMessageBox.Yes) != \
                        QtGui.QMessageBox.Yes: return

            logger.info(u"Send back: {}".format(inputs))
            self.accept()
            self._defered.callback(inputs)

        else:
            return
    def _display_questfinal(self):
        if not self._le2mserv.gestionnaire_base.is_created():
            QtGui.QMessageBox.warning(
                self._le2mserv.gestionnaire_graphique.screen,
                le2mtrans(u"Warning"),
                le2mtrans(u"There is no database yet. You first need to " u"load at least one part."),
            )
            return
        if not hasattr(self, "_tous"):
            QtGui.QMessageBox.warning(
                self._le2mserv.gestionnaire_graphique.screen,
                le2mtrans(u"Warning"),
                trans_TC(u"TeamCommunication has to be run before to " u"start this questionnaire"),
            )
            return

        confirmation = QtGui.QMessageBox.question(
            self._le2mserv.gestionnaire_graphique.screen,
            le2mtrans(u"Confirmation"),
            le2mtrans(u"Start the final questionnaire?"),
            QtGui.QMessageBox.Cancel | QtGui.QMessageBox.Ok,
        )
        if confirmation != QtGui.QMessageBox.Ok:
            return

        yield (
            self._le2mserv.gestionnaire_experience.run_step(
                trans_TC(u"Final questionnaire"), self._tous, "display_questfinal"
            )
        )
Example #15
0
 def _stoprepetitions(self, yes_or_no):
     if yes_or_no:
         self.action_stoprepetitions.setText(
             le2mtrans(u"The part will stop after this period"))
     else:
         self.action_stoprepetitions.setText(
             le2mtrans(u"Stop the part after this period "))
Example #16
0
    def display_payoffs_onserver(self, partname):
        """
        Open a dialog box with the payoffs
        """
        payoffs = []
        try:
            joueurs = sorted(self._le2msrv.gestionnaire_joueurs.get_players(partname), key=lambda x: x.joueur.hostname)
        except TypeError:  # no client connected
            QtGui.QMessageBox.warning(
                self._le2msrv.gestionnaire_graphique.screen, le2mtrans(u"warning"), le2mtrans(u"No client connected")
            )
            return
        try:
            if partname == "base":
                for j in joueurs:
                    payoffs.append([j.joueur.hostname, "{:.2f}".format(j.paiementFinal)])
            else:
                for j in joueurs:
                    gain_partie = getattr(j, "{}_gain_euros".format(j.nom_court))
                    payoffs.append([j.joueur.hostname, "{:.2f}".format(gain_partie)])

        except (AttributeError, KeyError) as e:
            QtGui.QMessageBox.critical(
                self._le2msrv.gestionnaire_graphique.screen,
                le2mtrans(u"Error"),
                le2mtrans(u"Error while getting payoffs for " u"part {}: {}").format(partname, e.message),
            )
            return

        self._screenpayoffs = GuiPayoffs(self._le2msrv, partname, payoffs)
        self._screenpayoffs.show()
Example #17
0
    def finalize_part(self, partname, *args, **kwargs):
        """
        Calcule le gain de la partie puis ajoute l'heure de fin et les
        textes de fin
        """
        if not self.has_part(partname):
            raise ValueError(le2mtrans(u"Part {p} not in the list").format(p=partname))

        # computation of part's payoffs
        logger.info(le2mtrans(u"Computation of payoffs for part {p}").format(p=partname))
        self._le2msrv.gestionnaire_graphique.infoclt(
            [None, le2mtrans(u"Payoffs of part {p}").format(p=partname.upper())], fg="red"
        )

        players = self._le2msrv.gestionnaire_joueurs.get_players(partname)
        yield (self.run_func(players, "compute_partpayoff", *args, **kwargs))

        for p in players:
            payoff = getattr(p, "{}_gain_euros".format(p.nom_court))
            self._le2msrv.gestionnaire_graphique.infoclt(u"{}: {}".format(p.joueur, payoff))
        self._le2msrv.gestionnaire_base.enregistrer()

        # Finalization of part
        self._le2msrv.gestionnaire_graphique.infoserv(le2mtrans(u"End time: {et}").format(et=strftime("%H:%M:%S")))
        self._le2msrv.gestionnaire_graphique.infoclt(u"Ok {}".format(partname).upper(), fg="white", bg="blue")
        self._le2msrv.gestionnaire_graphique.infoserv(u"Ok {}".format(partname).upper(), fg="white", bg="blue")
Example #18
0
 def _accept(self):
     if self._widheadtail.ui.pushButton_start.isEnabled():
         QtGui.QMessageBox.warning(
             self, le2mtrans(u"Warning"),
             le2mtrans(u"You must play"))
         return
     self.accept()
Example #19
0
 def remove_wait_mode(self, list_players):
     """
     Change the icon color to green, meaning that the remote has taken
     his decision
     :param list_players: either a list of players (or parts) or only one
      element (player or part)
     """
     if isinstance(list_players, list):
         for p in list_players:
             try:
                 index = self._players_wait_mode.index(p)
             except ValueError as e:
                 logger.warning(
                     le2mtrans(u"Problem with remove_waitmode: "
                               u"{msg}").format(e.message))
             else:
                 self.ui.listWidget_attente.item(index).setIcon(
                     self._icon_vert)
     else:
         try:
             index = self._players_wait_mode.index(list_players)
         except ValueError as e:
             logger.warning(
                 le2mtrans(u"Problem with remove_waitmode: "
                           u"{msg}").format(e.message))
         else:
             self.ui.listWidget_attente.item(index).setIcon(self._icon_vert)
Example #20
0
 def _print(self):
     """
     Print the table with the subjects' payoffs
     """
     if not self._payoffs:
         return
     html = u"<table align='center' border=1>\n<tr>" \
            u"<td align='center'><b>"
     html += le2mtrans(u"Hostname")
     html += u"</b></td>" \
             u"<td align='center'><b>"
     html += le2mtrans(u"Payoff")
     html += u"</b></td></tr>\n"
     for l in self._payoffs:
         html += u"<tr><td align='center'>{}</>" \
                 u"<td align='center'>{}&euro;</td>" \
                 u"</tr>\n".format(l[0], l[1])
     html += u"</table>\n"
     doc = QtGui.QTextDocument()
     doc.setHtml(html)
     printer = QtGui.QPrinter()
     dialog = QtGui.QPrintDialog(printer)
     dialog.setModal(True)
     dialog.setWindowTitle(le2mtrans(u"Payoffs"))
     if dialog.exec_():
         doc.print_(printer)
Example #21
0
    def finalize_part(self, partname, *args, **kwargs):
        """
        Calcule le gain de la partie puis ajoute l'heure de fin et les
        textes de fin
        """
        if not self.has_part(partname):
            raise ValueError(
                le2mtrans(u"Part {p} not in the list").format(p=partname))

        # computation of part's payoffs
        logger.info(
            le2mtrans(u"Computation of payoffs for part {p}").format(
                p=partname))
        self._le2msrv.gestionnaire_graphique.infoclt([
            None,
            le2mtrans(u'Payoffs of part {p}').format(p=partname.upper())
        ],
                                                     fg="red")

        players = self._le2msrv.gestionnaire_joueurs.get_players(partname)
        yield (self.run_func(players, "compute_partpayoff", *args, **kwargs))

        for p in players:
            payoff = getattr(p, "{}_gain_euros".format(p.nom_court))
            self._le2msrv.gestionnaire_graphique.infoclt(u"{}: {}".format(
                p.joueur, payoff))
        self._le2msrv.gestionnaire_base.enregistrer()

        # Finalization of part
        self._le2msrv.gestionnaire_graphique.infoserv(
            le2mtrans(u"End time: {et}").format(et=strftime("%H:%M:%S")))
        self._le2msrv.gestionnaire_graphique.infoclt(
            u'Ok {}'.format(partname).upper(), fg="white", bg="blue")
        self._le2msrv.gestionnaire_graphique.infoserv(
            u'Ok {}'.format(partname).upper(), fg="white", bg="blue")
    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
Example #23
0
 def _headtail(self):
     screen = DHeadtail(self)
     if screen.exec_():
         self._le2mserv.gestionnaire_graphique.infoserv(
             le2mtrans(u"Head and tail: {}".format(
                 le2mtrans(u"Head") if screen.get_value() ==
                 FACE else le2mtrans(u"Tail"))))
Example #24
0
 def _stoprepetitions(self, yes_or_no):
     if yes_or_no:
         self.action_stoprepetitions.setText(
             le2mtrans(u"The part will stop after this period"))
     else:
         self.action_stoprepetitions.setText(
             le2mtrans(u"Stop the part after this period "))
Example #25
0
 def _accept(self):
     if self._widrandint.ui.pushButton_start.isEnabled():
         QtGui.QMessageBox.warning(
             self, le2mtrans(u"Warning"),
             le2mtrans(u"You must drawn a random number"))
         return
     self.accept()
Example #26
0
    def _load_questcomp(self):
        """
        Récupère le fichier xml de questionnaire de compréhension et le
        traite
        :return:
        """
        xmlfile = str(
            QtGui.QFileDialog.getOpenFileName(
                self,
                le2mtrans(u"Select the understanding questionnaire to load"),
                "", le2mtrans(u"xml file (*.xml)")))
        if not xmlfile:
            return
        else:
            self._questcomp = questcomp.get_questions(xmlfile)
            if not self._questcomp:
                return

            txt = u""
            for q in self._questcomp:
                txt += u"{}\n\n".format(q)
            QtGui.QMessageBox.information(
                self,
                le2mtrans(u"Understanding questionnaire"), txt)
            self.add_serverlist(
                le2mtrans(u"Understanding questionnaire loaded "
                          u"({} questions)").format(len(self._questcomp)))
Example #27
0
    def creer_base(self, dossier, nom_fichier, istest):
        """
        Create the database.
        The database is named data.sqlite and is located in the directory that 
        starts the software.
        """
        fichier = "{}".format(os.path.join(dossier, nom_fichier))
        logger.info("database path: {}".format(fichier))
        engine = create_engine("sqlite:///{}".format(fichier), echo=False)
        DB.configure(bind=engine)
        self._db = DB()
        Base.metadata.create_all(engine)
        logger.info(le2mtrans("database created"))

        # add the session to the database
        self._session = Session(self._nom_session, self._heure_debut, istest)
        self.ajouter(self._session)
        logger.info(le2mtrans(u"Session {s} added to the database").format(
            s=self._nom_session))

        # add the connected players to the database
        for j in self._playerstoadd:
            logger.info(le2mtrans(u"Player {p} added to the "
                                  u"session").format(p=j))
            self.ajouter(j)
            self._session.joueurs.append(j)
        del self._playerstoadd[:]

        self.enregistrer()
    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())
Example #29
0
def get_histo_head():
    return [
        le2mtrans(u"Period"),
        le2mtrans(u"Decision"),
        le2mtrans(u"Period\npayoff"),
        le2mtrans(u"Cumulative\npayoff")
    ]
Example #30
0
    def load_experiment(self, expeinfos):
        """
        - Load the experiment, i.e. the parts selected by the experimenter
        - Create the database
        :param expeinfos: namedtuplue with the informations for creating the
        experiment
        """
        # load of parts
        for p in expeinfos.parts:
            try:
                module = importlib.import_module("parts.{0}.{0}Serv".format(p))
                serv = getattr(module, "Serveur")
                self._servs[p] = serv(self._le2msrv)
                self._le2msrv.gestionnaire_graphique.infoserv(
                    le2mtrans(u"Part") + " {} ".format(p) +
                    le2mtrans(u"loaded"))
            except ImportError as e:
                logger.critical(u"Error while loading part {p}: {msg}".format(
                    p=p, msg=e.message))

        # database creation
        if not self._le2msrv.gestionnaire_base.is_created():
            self._le2msrv.gestionnaire_base.creer_base(expeinfos.dirbase,
                                                       expeinfos.basename,
                                                       expeinfos.istest)
    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
Example #33
0
    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())
Example #34
0
    def creer_base(self, dossier, nom_fichier, istest):
        """
        Create the database.
        The database is named data.sqlite and is located in the directory that 
        starts the software.
        """
        fichier = "{}".format(os.path.join(dossier, nom_fichier))
        logger.info("database path: {}".format(fichier))
        engine = create_engine("sqlite:///{}".format(fichier), echo=False)
        DB.configure(bind=engine)
        self._db = DB()
        Base.metadata.create_all(engine)
        logger.info(le2mtrans("database created"))

        # add the session to the database
        self._session = Session(self._nom_session, self._heure_debut, istest)
        self.ajouter(self._session)
        logger.info(
            le2mtrans(u"Session {s} added to the database").format(
                s=self._nom_session))

        # add the connected players to the database
        for j in self._playerstoadd:
            logger.info(
                le2mtrans(u"Player {p} added to the "
                          u"session").format(p=j))
            self.ajouter(j)
            self._session.joueurs.append(j)
        del self._playerstoadd[:]

        self.enregistrer()
Example #35
0
    def _load_questcomp(self):
        """
        Récupère le fichier xml de questionnaire de compréhension et le
        traite
        :return:
        """
        xmlfile = str(
            QtGui.QFileDialog.getOpenFileName(
                self,
                le2mtrans(u"Select the understanding questionnaire to load"),
                "", le2mtrans(u"xml file (*.xml)")))
        if not xmlfile:
            return
        else:
            self._questcomp = questcomp.get_questions(xmlfile)
            if not self._questcomp:
                return

            txt = u""
            for q in self._questcomp:
                txt += u"{}\n\n".format(q)
            QtGui.QMessageBox.information(
                self, le2mtrans(u"Understanding questionnaire"), txt)
            self.add_serverlist(
                le2mtrans(u"Understanding questionnaire loaded "
                          u"({} questions)").format(len(self._questcomp)))
    def __init__(self, le2mserv):
        self._le2mserv = le2mserv
        
        # self._traitements_lances = []
        self._current_sequence = 0

        actions = OrderedDict()
        actions[u"Changer le paramètre 'ordre'"] = self._changer_ordre
        actions[le2mtrans(u"Display parameters")] = \
            lambda _: self._le2mserv.gestionnaire_graphique. \
            display_information2(
                utiltools.get_module_info(pms), le2mtrans(u"Parameters"))
        actions[u"Démarrer - baseline"] = lambda _: self._demarrer(
            pms.BASELINE)
        actions[u"Démarrer - prélèvement"] = lambda _: self._demarrer(
            pms.PRELEVEMENT)
        actions[u"Démarrer - désapprobation"] = lambda _: self._demarrer(
            pms.DESAPPROBATION)
        actions[u"Démarrer - désapprobation avec prélèvement"] = lambda _: \
            self._demarrer(pms.DESAPPROBATION_PRELEVEMENT)
        actions[u"Afficher les gains"] = lambda _: self._le2mserv. \
            gestionnaire_experience.display_payoffs_onserver(
            "bienPublicKate")
        self._le2mserv.gestionnaire_graphique.add_topartmenu(
            u"Bien Public Kate", actions)
Example #37
0
    def __init__(self, liste_joueurs, parent=None):
        super(GuiGenres, self).__init__(parent)

        # variables
        self._liste_joueurs = liste_joueurs

        # création gui
        self.ui = servguigenders.Ui_Dialog()
        self.ui.setupUi(self)

        # explication
        self.ui.textEdit_explication.setFixedSize(350, 30)
        self.ui.textEdit_explication.setText(
            le2mtrans(u"Please check the men and let the women unchecked."))

        # listView
        self.ui.listView.setFixedSize(350, 350)
        self._model = QtGui.QStandardItemModel()
        for j in self._liste_joueurs:
            item = QtGui.QStandardItem(str(j))
            item.setCheckState(QtCore.Qt.Unchecked)
            item.setCheckable(True)
            item.setEditable(False)
            self._model.appendRow(item)
        self.ui.listView.setModel(self._model)

        self.ui.buttonBox.accepted.connect(self._accept)
        self.ui.buttonBox.rejected.connect(self.reject)
        self.setWindowTitle(le2mtrans(u"Set subjects' gender"))
        self.setFixedSize(400, 550)
    def _accept(self):
        try:
            self._timer_automatique.stop()
        except AttributeError:
            pass

        try:
            reponses = {}
            for k, v in self._reponses_widgets.viewitems():
                reponses[k] = (v[0].get_checkedbutton(),
                                      v[1].get_checkedbutton())
        except ValueError:
            QtGui.QMessageBox.warning(
                self, le2mtrans(u"Warning"),
                trans_RR(u"You must answer to all the questions"))
            return

        if not self._automatique:
            confirmation = QtGui.QMessageBox.question(
                self, le2mtrans(u"Confirmation"),
                le2mtrans(u"Do you confirm your choices?"),
                QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)
            if confirmation != QtGui.QMessageBox.Yes: 
                return
        logger.info(u"Send back {}".format(reponses))
        self.accept()
        self._defered.callback(reponses)
Example #39
0
 def _accept(self):
     try:
         self._timer_automatique.stop()
     except AttributeError:
         pass
     inputs = self._get_inputs()
     if inputs is None:
         return
     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
     inputs["couple"] = None
     inputs["fratrie_nombre"] = None
     inputs["fratrie_rang"] = None
     inputs["sportif"] = None
     inputs["sportif_type"] = None
     inputs["sportif_competition"] = None
     inputs["religion_place"] = None
     inputs["religion_croyance"] = None
     inputs["religion_nom"] = None
     logger.info(u"Send back: {}".format(inputs))
     self.accept()
     self._defered.callback(inputs)
Example #40
0
    def __init__(self, le2mserv, partname, payoffs):
        super(GuiPayoffs, self).__init__()
        self._le2mserv = le2mserv
        self._partname = partname
        self._payoffs = payoffs

        # creation gui
        self.ui = servguipayoffs.Ui_Dialog()
        self.ui.setupUi(self)

        # table model for displaying payoffs
        self._tableModel = TableModelPaiements(self._payoffs)
        self.ui.tableView.setModel(self._tableModel)
        self.ui.tableView.horizontalHeader().setResizeMode(
            QtGui.QHeaderView.Stretch)

        # slot
        self.ui.pushButton_imprimer.clicked.connect(self._print)
        self.ui.pushButton_enregistrer.clicked.connect(self._save)
        self.ui.pushButton_afficher.clicked.connect(self._display_onremotes)
        self.ui.pushButton_ajouter.clicked.connect(self._addto_finalpayoffs)

        if self._partname == "base":
            self.setWindowTitle(le2mtrans(u"Payoffs for the experiment"))
            self.ui.pushButton_ajouter.setEnabled(False)
        else:
            self.setWindowTitle(
                le2mtrans(u"Payoffs of part {}").format(self._partname))
        self.setFixedSize(550, 608)
Example #41
0
def get_payoff_text(pay_euros, pay_ecus=None):
    if pay_ecus is not None:
        txt = le2mtrans(u"You've earned {} which corresponds to {}.").format(
            get_pluriel(pay_ecus, u"ecu"), get_pluriel(pay_euros, u"euro"))
    else:
        txt = le2mtrans(u"You've earned {}.".format(
            get_pluriel(pay_euros, u"euro")))
    return txt
Example #42
0
def get_payoff_text(pay_euros, pay_ecus=None):
    if pay_ecus is not None:
        txt = le2mtrans(u"You've earned {} which corresponds to {}.").format(
            get_pluriel(pay_ecus, u"ecu"), get_pluriel(pay_euros, u"euro"))
    else:
        txt = le2mtrans(u"You've earned {}.".format(
            get_pluriel(pay_euros, u"euro")))
    return txt
Example #43
0
 def set_genres(self, dict_genres):
     for k, v in dict_genres.iteritems():
         k.set_genre(v)
     hommes = [j for j in self.get_players() if j.genre == HOMME]
     femmes = [j for j in self.get_players() if j.genre == FEMME]
     self._main_serveur.gestionnaire_graphique.infoserv(
         [None, le2mtrans(u"Subjects' gender"),
          le2mtrans(u"Men: {m}").format(m=hommes),
          le2mtrans(u"Women: {w}").format(w=femmes)])
Example #44
0
 def __init__(self, parent=None):
     super(TableModelJoueurs, self).__init__(parent)
     self._headers = [
         'uid',
         le2mtrans('Hostname'), 'IP',
         le2mtrans('Automatic'),
         le2mtrans('Simulation'),
         le2mtrans(u'Disconnect')
     ]
     self._joueurs = []
Example #45
0
 def _display_welcome(self):
     """
     Display the welcome screen on remotes
     """
     reply = QtGui.QMessageBox.question(
         self, le2mtrans(u'Confirmation'),
         le2mtrans(u"Display the welcome screen on remotes?"),
         QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
     if reply != QtGui.QMessageBox.Yes:
         return
     self._le2mserv.gestionnaire_experience.display_welcome()
Example #46
0
    def __init__(self, le2mserv):
        super(GuiServeur, self).__init__()

        self._le2mserv = le2mserv
        self._questcomp = None

        self.ui = servguimain.Ui_EcranServeur()
        self.ui.setupUi(self)
        self._create_menus()

        self.ui.label_le2m.setText(le2mtrans(u"LE2M\nExperimental Economics Software of Montpellier"))

        # tabs
        self.ui.onglets.setTabText(self.ui.onglets.indexOf(self.ui.tabInfos), le2mtrans(u"Informations"))
        self.ui.onglets.setTabText(self.ui.onglets.indexOf(self.ui.tabClients), le2mtrans(u"Remotes"))
        self.ui.onglets.setTabText(self.ui.onglets.indexOf(self.ui.tabExperience), le2mtrans(u"Experiment"))

        # picture on the first tab ---------------------------------------------
        try:
            img_labo_pix = QtGui.QPixmap(params.getp("LABLOGO"))
            self.ui.label_logo_laboratoire.setPixmap(img_labo_pix)
        except IOError:
            logger.warning(u"Error while loading LABLOGO picture")
            self.ui.label_logo_laboratoire.setText(le2mtrans(u"Here the logo of the lab"))
        try:
            img_leem_pix = QtGui.QPixmap(params.getp("LABPICTURE"))
            self.ui.label_image_centre.setPixmap(img_leem_pix)
        except IOError:
            logger.warning(u"Error while loading LABPICTURE picture")
            self.ui.label_image_centre.setText(le2mtrans(u"Here the main picture"))

        # icons for the waiting mode -------------------------------------------
        self._icon_rouge = QtGui.QIcon(os.path.join(params.getp("IMGDIR"), "red.png"))
        self._icon_vert = QtGui.QIcon(os.path.join(params.getp("IMGDIR"), "green.png"))
        self.ui.label_attente.setText(le2mtrans(u"Decisions"))
        self._players_wait_mode = list()

        # server infos ---------------------------------------------------------
        self.ui.label_infos_serveur.setText(
            u"OS: {} {} | Python version: {} | Hostname: {} | IP: {}".format(
                platform.uname()[0],
                platform.uname()[2],
                sys.version.split()[0],
                self._le2mserv.hostname,
                self._le2mserv.ip,
            )
        )

        # table on the second tab with connected remotes -----------------------
        # handle automatic and simulation modes as well as remotes' deconnection
        self.ui.label_connectedremotes.setText(le2mtrans(u"Connected remotes: 0"))
        self.tableJoueurs = TableModelJoueurs()
        self.ui.tv_clients_connectes.setModel(self.tableJoueurs)
        self.ui.tv_clients_connectes.horizontalHeader().setResizeMode(QtGui.QHeaderView.Stretch)
        self.ui.tv_clients_connectes.horizontalHeader().setClickable(True)
        self.ui.tv_clients_connectes.horizontalHeader().sectionClicked[int].connect(self.tableJoueurs.inverse)
        self.ui.onglets.setCurrentIndex(0)

        self.setWindowTitle(le2mtrans(u"LE2M"))
Example #47
0
 def _edit_genders(self):
     """
     Display a dialog for setting the gender of each subject (by remote)
     """
     players = self._le2mserv.gestionnaire_joueurs.get_players()
     ecran_genres = GuiGenres(players, self)
     if ecran_genres.exec_():
         self._le2mserv.gestionnaire_graphique.infoserv([le2mtrans(u"Genders"), le2mtrans(u"Men")])
         self._le2mserv.gestionnaire_graphique.infoserv(map(str, [p for p in players if p.gender == HOMME]))
         self._le2mserv.gestionnaire_graphique.infoserv(le2mtrans(u"Women"))
         self._le2mserv.gestionnaire_graphique.infoserv(map(str, [p for p in players if p.gender == FEMME]))
Example #48
0
 def set_genres(self, dict_genres):
     for k, v in dict_genres.iteritems():
         k.set_genre(v)
     hommes = [j for j in self.get_players() if j.genre == HOMME]
     femmes = [j for j in self.get_players() if j.genre == FEMME]
     self._main_serveur.gestionnaire_graphique.infoserv([
         None,
         le2mtrans(u"Subjects' gender"),
         le2mtrans(u"Men: {m}").format(m=hommes),
         le2mtrans(u"Women: {w}").format(w=femmes)
     ])
Example #49
0
    def _get_inputs(self):
        inputs = {}
        try:
            birth = self._birth.get_value()
            if birth == datetime.now().year:
                raise ValueError(le2mtrans(u"Please enter your year of birth"))
            else:
                inputs['naissance'] = birth
            inputs["nationalite"] = self._nationality.get_currentindex()
            inputs["genre"] = self._gender.get_checkedbutton()
            inputs['couple'] = self._couple.get_checkedbutton()
            inputs['experiences'] = self._expe.get_checkedbutton()

            # student
            inputs['etudiant'] = self._study.get_checkedbutton()
            if inputs['etudiant'] == 0:
                inputs[
                    'etudiant_discipline'] = self._study_topic.get_currentindex(
                    )
                inputs['etudiant_niveau'] = self._study_level.get_currentindex(
                )

            # brotherhood
            inputs["fratrie_nombre"] = self._brothers.get_value()
            if inputs["fratrie_nombre"] > 0:
                inputs["fratrie_rang"] = self._brothers_rank.get_value()
            else:
                inputs["fratrie_rang"] = 0

            # sport
            inputs["sportif"] = self._sport.get_checkedbutton()
            if inputs["sportif"] == 0:
                inputs[
                    "sportif_type"] = self._sport_individuel.get_checkedbutton(
                    )
                inputs[
                    "sportif_competition"] = self._sport_competition.get_checkedbutton(
                    )

            # religion
            inputs['religion_place'] = self._religion_place.get_currentindex()
            inputs[
                'religion_croyance'] = self._religion_belief.get_currentindex(
                )
            inputs['religion_nom'] = self._religion_name.get_currentindex()

        except ValueError:
            QtGui.QMessageBox.warning(
                self, le2mtrans(u"Warning"),
                le2mtrans(u"You must answer to all the questions"))
            return None

        return inputs
Example #50
0
    def __init__(self, parent=None):
        super(GuiPartLoad, self).__init__(parent)

        self.ui = servguipartsload.Ui_Dialog()
        self.ui.setupUi(self)

        # parts list
        self.ui.label_explication.setText(
            le2mtrans(u"Please select in the list below the parts you want "
                      u"to load"))
        self.ui.listView.setToolTip(
            QtCore.QString(le2mtrans(u"Select the part(s) you want to load")))

        # database directory
        self.ui.label_basepath.setText(
            le2mtrans(u"Directory in which to store the database"))
        self.ui.label_basepath1.setText(le2mtrans(u"Directory path (check)"))
        self.ui.label_basepath2.setText("...")

        # database name
        self.ui.label_basename.setText(
            le2mtrans(u"Database name (without the sqlite extension"))
        self.ui.lineEdit_nom_base.setText(u"data")
        self.ui.label_nom_base_extension.setText(u".sqlite")

        # test session
        self.ui.label_test.setText(le2mtrans(u"Test session"))
        self.ui.checkBox_test.setToolTip(
            le2mtrans(u"Uncheck if this is not a test session"))
        self.ui.checkBox_test.setChecked(True)

        self.ui.pushButton_base.setText(le2mtrans(u"Browse"))

        # connections
        self.ui.pushButton_base.clicked.connect(self._set_directorydatabase)
        self.ui.buttonBox.accepted.connect(self._accept)
        self.ui.buttonBox.rejected.connect(self.reject)

        # list of parts in the PARTSDIR directory
        partslist = [
            f for f in os.listdir(params.getp("PARTSDIR"))
            if os.path.isdir(os.path.join(params.getp("PARTSDIR"), f))
            and not f.startswith(".")
        ]
        partslist.sort()

        self._model = QtGui.QStandardItemModel()
        for p in partslist:
            item = QtGui.QStandardItem(p)
            item.setCheckState(QtCore.Qt.Unchecked)
            item.setCheckable(True)
            item.setEditable(False)
            self._model.appendRow(item)
        self._model.itemChanged.connect(self._onitemchanged)
        self.ui.listView.setModel(self._model)

        self.setWindowTitle(le2mtrans(u"List of parts that can be loaded"))
        self.adjustSize()
Example #51
0
 def stop_repetitions(self, vrai_ou_faux):
     """
     Stop (or cancel) the part at the next period. Emit a signal in order
     the le2m server screen to update (menu options)
     :param vrai_ou_faux:
     :return:
     """
     self._stop_repetitions = vrai_ou_faux
     if self._stop_repetitions:
         logger.info(le2mtrans(u"The game will stop next period"))
     else:
         logger.info(le2mtrans(u"The game won't stop next period"))
     self.stoprepetitions.emit(self.stop_repetitions)
Example #52
0
 def closeEvent(self, event):
     """
     Parce qu'on demande confirmation avant de quitter
     """
     reply = QtGui.QMessageBox.question(
         self, le2mtrans(u'Confirmation'),
         le2mtrans(u"Are you sure you want to exit LE2M?"),
         QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
     if reply == QtGui.QMessageBox.Yes:
         self._le2mserv.arreter()
         event.accept()
     else:
         event.ignore()
Example #53
0
 def _display_welcome(self):
     """
     Display the welcome screen on remotes
     """
     reply = QtGui.QMessageBox.question(
         self,
         le2mtrans(u'Confirmation'),
         le2mtrans(u"Display the welcome screen on remotes?"),
         QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
     )
     if reply != QtGui.QMessageBox.Yes:
         return
     self._le2mserv.gestionnaire_experience.display_welcome()
Example #54
0
 def stop_repetitions(self, vrai_ou_faux):
     """
     Stop (or cancel) the part at the next period. Emit a signal in order
     the le2m server screen to update (menu options)
     :param vrai_ou_faux:
     :return:
     """
     self._stop_repetitions = vrai_ou_faux
     if self._stop_repetitions:
         logger.info(le2mtrans(u"The game will stop next period"))
     else:
         logger.info(le2mtrans(u"The game won't stop next period"))
     self.stoprepetitions.emit(self.stop_repetitions)
Example #55
0
    def __init__(self, parent=None):
        super(GuiPartLoad, self).__init__(parent)

        self.ui = servguipartsload.Ui_Dialog()
        self.ui.setupUi(self)

        # parts list
        self.ui.label_explication.setText(
            le2mtrans(u"Please select in the list below the parts you want "
                      u"to load"))
        self.ui.listView.setToolTip(QtCore.QString(
            le2mtrans(u"Select the part(s) you want to load")))

        # database directory
        self.ui.label_basepath.setText(
            le2mtrans(u"Directory in which to store the database"))
        self.ui.label_basepath1.setText(le2mtrans(u"Directory path (check)"))
        self.ui.label_basepath2.setText("...")

        # database name
        self.ui.label_basename.setText(
            le2mtrans(u"Database name (without the sqlite extension"))
        self.ui.lineEdit_nom_base.setText(u"data")
        self.ui.label_nom_base_extension.setText(u".sqlite")

        # test session
        self.ui.label_test.setText(le2mtrans(u"Test session"))
        self.ui.checkBox_test.setToolTip(
            le2mtrans(u"Uncheck if this is not a test session"))
        self.ui.checkBox_test.setChecked(True)

        self.ui.pushButton_base.setText(le2mtrans(u"Browse"))

        # connections
        self.ui.pushButton_base.clicked.connect(self._set_directorydatabase)
        self.ui.buttonBox.accepted.connect(self._accept)
        self.ui.buttonBox.rejected.connect(self.reject)

        # list of parts in the PARTSDIR directory
        partslist = [f for f in os.listdir(params.getp("PARTSDIR")) if
                     os.path.isdir(os.path.join(params.getp("PARTSDIR"), f)) and
                     not f.startswith(".")]
        partslist.sort()

        self._model = QtGui.QStandardItemModel()
        for p in partslist:
            item = QtGui.QStandardItem(p)
            item.setCheckState(QtCore.Qt.Unchecked)
            item.setCheckable(True)
            item.setEditable(False)
            self._model.appendRow(item)
        self._model.itemChanged.connect(self._onitemchanged)
        self.ui.listView.setModel(self._model)

        self.setWindowTitle(le2mtrans(u"List of parts that can be loaded"))
        self.adjustSize()
Example #56
0
 def closeEvent(self, event):
     """
     Parce qu'on demande confirmation avant de quitter
     """
     reply = QtGui.QMessageBox.question(
         self,
         le2mtrans(u'Confirmation'),
         le2mtrans(u"Are you sure you want to exit LE2M?"),
         QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
     if reply == QtGui.QMessageBox.Yes:
         self._le2mserv.arreter()
         event.accept()
     else:
         event.ignore()
    def _accept(self):
        try:
            self._timer_automatique.stop()
        except AttributeError:
            pass
        inputs = self._get_inputs()
        if type(inputs) is dict:

            try:

                inputs["residence"] = self._residence.get_currentindex()
                inputs["luxembourgish_speak"] = self._luxembourgish_speak.get_currentindex()
                inputs["luxembourgish_understand"] = self._luxembourgish_understrand.get_currentindex()
                inputs["luxembourgish_read"] = self._luxembourgish_read.get_currentindex()
                inputs["luxembourgish_write"] = self._luxembourgish_write.get_currentindex()
                inputs["french_speak"] = self._french_speak.get_currentindex()
                inputs["french_understand"] = self._french_understrand.get_currentindex()
                inputs["french_read"] = self._french_read.get_currentindex()
                inputs["french_write"] = self._french_write.get_currentindex()
                inputs["german_speak"] = self._german_speak.get_currentindex()
                inputs["german_understand"] = self._german_understrand.get_currentindex()
                inputs["german_read"] = self._german_read.get_currentindex()
                inputs["german_write"] = self._german_write.get_currentindex()
                inputs["english_speak"] = self._english_speak.get_currentindex()
                inputs["english_understand"] = self._english_understrand.get_currentindex()
                inputs["english_read"] = self._english_read.get_currentindex()
                inputs["english_write"] = self._english_write.get_currentindex()
                if inputs["etudiant"] == 1:  # not student
                    inputs["profession"] = self._profession.get_currentindex()

            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
Example #58
0
 def _load_parts(self):
     if self._le2mserv.gestionnaire_base.is_created():
         QtGui.QMessageBox.warning(
             self, le2mtrans(u"Warning"),
             le2mtrans(u"The database is already created, you therefore "
                       u"cannot load another part. If you want to, you need "
                       u"to restart the application"))
         return
     screenparts = GuiPartLoad(self)
     if screenparts.exec_():
         expeinfos = screenparts.get_expeinfos()
         logger.info(le2mtrans(u"Experiment: {e}").format(e=expeinfos))
         self._le2mserv.gestionnaire_experience.load_experiment(expeinfos)
     else:
         return
Example #59
0
def get_histo_head(role):
    header = [le2mtrans(u"Period")]
    if role == pms.ACHETEUR:
        header.append(u"Valeur")
    else:
        header.append(u"Coût")

    header.extend([u"Prix\nde\ntransaction", u"Prime\nde\ntransaction"])

    if (pms.TREATMENT == pms.TAXE_UNITE or pms.TREATMENT == pms.TAXE_VALEUR) and \
        role == pms.VENDEUR:
        header.append(u"Taxe")

    header.extend([le2mtrans(u"Period\npayoff")])
    return header
Example #60
0
    def _display_onremotes(self):
        text_temp = le2mtrans(u"the experiment") if \
            self._partname == "base" else self._partname
        confirmation = QtGui.QMessageBox.question(
            self, u"Confirmation",
            le2mtrans(u"Display the payoffs of {}?").format(text_temp),
            QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)
        if confirmation != QtGui.QMessageBox.Yes:
            return

        if self._partname == "base":
            self._le2mserv.gestionnaire_experience.display_finalscreen()
        else:
            self._le2mserv.gestionnaire_experience.display_payoffs_onremotes(
                self._partname)