def __init__(self, serv_screen, players, players_A=None): QtGui.QDialog.__init__(self, serv_screen) self._players = players layout = QtGui.QVBoxLayout() self.setLayout(layout) wexplic = WExplication(parent=self, text=u"Déplacer les joueurs A dans la liste de " u"droite", size=(450, 30)) layout.addWidget(wexplic) self._drag = WListDrag(parent=self, size=(300, 200)) layout.addWidget(self._drag) self._drag.ui.listWidget_left.addItems([u"{} / {}".format(p.hostname, p) for p in self._players]) if players_A: self._drag.ui.listWidget_right.addItems( [u"{} / {}".format(p.hostname, p) for p in players_A]) buttons = QtGui.QDialogButtonBox( QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok) layout.addWidget(buttons) buttons.accepted.connect(self._accept) buttons.rejected.connect(self.reject) self.adjustSize()
def __init__(self, remote, defered): QDialog.__init__(self, remote.le2mclt.screen) self.remote = remote self.defered = defered layout = QVBoxLayout() self.setLayout(layout) explanation_area = WExplication(parent=self, text=texts_CO.INITIAL_EXTRACTION) layout.addWidget(explanation_area) self.slider_area = MySlider() layout.addWidget(self.slider_area) buttons = QDialogButtonBox(QDialogButtonBox.Ok) buttons.accepted.connect(self._accept) layout.addWidget(buttons) self.setWindowTitle("Decision") self.adjustSize() self.setFixedSize(self.size()) if self.remote.le2mclt.automatique: self.slider_area.slider.setValue( random.randint(pms.DECISION_MIN, pms.DECISION_MAX * int(1 / pms.DECISION_STEP))) self.timer_automatique = QTimer() self.timer_automatique.timeout.connect( buttons.button(QDialogButtonBox.Ok).click) self.timer_automatique.start(7000)
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 __init__(self, defered, automatique, parent, num_question, matrice): super(GuiDecision, self).__init__(parent) # variables self._defered = defered self._automatique = automatique self.matrice = matrice layout = QtGui.QVBoxLayout(self) wexplanation = WExplication(text=texts_SVO.get_text_explanation(), size=(650, 150), parent=self) layout.addWidget(wexplanation) if pms.DISPLAY == pms.DISPLAY_SLIDER: self.wslider = WSlide(self, self.matrice, self._automatique) layout.addWidget(self.wslider) elif pms.DISPLAY == pms.DISPLAY_RADIO: self.wmatrice = WMatrice(self, self.matrice, self._automatique) layout.addWidget(self.wmatrice) buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) buttons.accepted.connect(self._accept) layout.addWidget(buttons) self.setWindowTitle(trans_SVO(u"Question {}".format(num_question))) self.adjustSize() self.setFixedSize(self.size()) if self._automatique: self._timer_automatique = QtCore.QTimer() self._timer_automatique.timeout.connect( buttons.button(QtGui.QDialogButtonBox.Ok).click) self._timer_automatique.start(7000)
def __init__(self, defered, automatique, parent): super(DVote, self).__init__(parent) self._defered = defered self._automatique = automatique layout = QtGui.QVBoxLayout(self) self._explanation = WExplication(parent=self, text=texts_PGGS.get_text_vote(), size=(450, 80)) layout.addWidget(self._explanation) self._vote = WRadio( parent=self, automatique=self._automatique, label=texts_PGGS.trans_PGGS(u"Your vote"), texts=[v for k, v in sorted(texts_PGGS.VOTES.viewitems())]) layout.addWidget(self._vote) buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) buttons.accepted.connect(self._accept) layout.addWidget(buttons) self.setWindowTitle(texts_PGGS.trans_PGGS(u"Vote")) self.adjustSize() self.setFixedSize(self.size()) if self._automatique: self._timer = QtCore.QTimer() self._timer.timeout.connect( buttons.button(QtGui.QDialogButtonBox.Ok).click) self._timer.start(7000)
def __init__(self, defered, automatique, parent, periode, historique, grilles): QtGui.QDialog.__init__(self, parent) self._defered = defered self._automatique = automatique self._grilles = grilles self._historique = GuiHistorique(self, historique, size=(HISTO_WIDTH, 500)) layout = QtGui.QVBoxLayout() self.setLayout(layout) # period and history button wperiod = WPeriod(period=periode, ecran_historique=self._historique, parent=self) layout.addWidget(wperiod) explanation = WExplication( parent=self, text=texts_PGGS.get_text_explanation_grilles(), size=(600, 100)) layout.addWidget(explanation) self._countdown = WCompterebours(self, temps=pms.TIME_TO_FILL_GRILLES, actionfin=self._accept) layout.addWidget(self._countdown) grid_layout = QtGui.QGridLayout() layout.addLayout(grid_layout) self._widgets_grilles = list() current_line = 0 for i, g in enumerate(self._grilles): self._widgets_grilles.append(WGrid(g, self._automatique)) grid_layout.addWidget(self._widgets_grilles[-1], current_line, i - current_line * pms.NB_GRILLES_PER_LINE) if i > 0 and (i + 1) % pms.NB_GRILLES_PER_LINE == 0: current_line += 1 buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) buttons.accepted.connect(self._accept) layout.addWidget(buttons) self.adjustSize() self.setFixedSize(self.size()) self.setWindowTitle(trans_PGGS(u"Tasks"))
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 __init__(self, defered, automatique, parent, text): QtGui.QDialog.__init__(self, parent) self._defered = defered self._automatique = automatique layout = QtGui.QVBoxLayout() self.setLayout(layout) explanation = WExplication(text[0]) layout.addWidget(explanation) form_layout = QtGui.QFormLayout() layout.addLayout(form_layout) self._spin_expectation_favor = QtGui.QSpinBox() self._spin_expectation_favor.setMinimum(pms.DECISION_MIN) self._spin_expectation_favor.setMaximum(pms.DECISION_MAX) self._spin_expectation_favor.setButtonSymbols(QtGui.QSpinBox.NoButtons) form_layout.addRow(QtGui.QLabel(text[1]), self._spin_expectation_favor) self._spin_expectation_against = QtGui.QSpinBox() self._spin_expectation_against.setMinimum(pms.DECISION_MIN) self._spin_expectation_against.setMaximum(pms.DECISION_MAX) self._spin_expectation_against.setButtonSymbols( QtGui.QSpinBox.NoButtons) form_layout.addRow(QtGui.QLabel(text[2]), self._spin_expectation_against) 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._spin_expectation_favor.setValue(randint(0, pms.DECISION_MAX)) self._spin_expectation_against.setValue( randint(0, pms.DECISION_MAX)) self._timer = QtCore.QTimer() self._timer.timeout.connect(self._accept) self._timer.start(7000)
def __init__(self, defered, automatique, parent): super(DDecisionA, self).__init__(parent) self._defered = defered self._automatique = automatique layout = QtGui.QVBoxLayout(self) self._widexplication = WExplication( parent=self, text=texts_OL.get_text_explanation(pms.JOUEUR_A), size=(450, 80)) layout.addWidget(self._widexplication) self._widgains = WGains(automatique=self._automatique, parent=self) layout.addWidget(self._widgains) self._widdicetoss = WDiceToss(parent=self, automatique=self._automatique) self._widdicetoss.setEnabled(False) layout.addWidget(self._widdicetoss) self._widChoicemsg = WChoiceMsg(parent=self, automatique=self._automatique) self._widChoicemsg.setEnabled(False) layout.addWidget(self._widChoicemsg) self._buttons = QtGui.QDialogButtonBox( QtGui.QDialogButtonBox.Ok, QtCore.Qt.Horizontal, self) self._buttons.accepted.connect(self._accept) self._buttons.setEnabled(False) layout.addWidget(self._buttons) self._set_connections() if self._automatique: self._timer = QtCore.QTimer() self._timer.timeout.connect( self._buttons.button(QtGui.QDialogButtonBox.Ok).click) self._timer.start(8000) self.setWindowTitle(le2mtrans(u"Decision")) self.adjustSize() self.setFixedSize(self.size())
def __init__(self, defered, automatique, parent, period, historique): super(GuiDecision, self).__init__(parent) # variables self._defered = defered self._automatique = automatique self._historique = GuiHistorique(self, historique) layout = QtGui.QVBoxLayout(self) # should be removed if one-shot game wperiod = WPeriod(period=period, ecran_historique=self._historique) layout.addWidget(wperiod) wexplanation = WExplication( text=texts_EXPERIENCE_NOM_COURT.get_text_explanation(), size=(450, 80), parent=self) layout.addWidget(wexplanation) self._wdecision = WSpinbox( label=texts_EXPERIENCE_NOM_COURT.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_EXPERIENCE_NOM_COURT(u"Décision")) 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 __init__(self, remote, defered): QDialog.__init__(self, remote.le2mclt.screen) self.remote = remote self.defered = defered layout = QVBoxLayout() self.setLayout(layout) explanation_area = WExplication(parent=self, text=texts_CO.INITIAL_EXTRACTION) layout.addWidget(explanation_area) self.slider_area = MySlider() layout.addWidget(self.slider_area) buttons = QDialogButtonBox(QDialogButtonBox.Ok) buttons.accepted.connect(self._accept) layout.addWidget(buttons) self.setWindowTitle("Decision") self.adjustSize() self.setFixedSize(self.size()) if self.remote.le2mclt.automatique: if self.remote.simulation_extraction == 0: self.slider_area.setValue( pms.get_extraction_my(self.remote.current_instant)) elif self.remote.simulation_extraction == 1: self.slider_area.setValue( pms.get_extraction_os(self.remote.current_instant)) elif self.remote.simulation_extraction == 2: self.slider_area.setValue( pms.get_extraction_feed(self.remote.current_instant)) else: self.slider_area.setValue( pms.get_extraction_aleatoire(self.remote.current_instant)) self.timer_automatique = QTimer() self.timer_automatique.timeout.connect( buttons.button(QDialogButtonBox.Ok).click) self.timer_automatique.start(3000)
def __init__(self, defered, automatique, parent, periode, historique): super(GuiDecision, self).__init__(parent) # variables self._defered = defered self._automatique = automatique self._historique = GuiHistorique(self, historique) layout = QtGui.QVBoxLayout(self) wperiod = WPeriod(period=periode, ecran_historique=self._historique, parent=self) layout.addWidget(wperiod) wexplanation = WExplication(text=texts_DP.get_text_explanation(), parent=self, size=(450, 80)) layout.addWidget(wexplanation) options = tuple([v for k, v in sorted(pms.OPTIONS.viewitems())]) self._wdecision = WRadio(texts=options, label=trans_DP(u"Choose an option"), parent=self, automatique=self._automatique) layout.addWidget(self._wdecision) buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) buttons.accepted.connect(self._accept) layout.addWidget(buttons) self.setWindowTitle(le2mtrans(u"Decision")) self.adjustSize() self.setFixedSize(self.size()) if self._automatique: self._timer_automatique = QtCore.QTimer() self._timer_automatique.timeout.connect( buttons.button(QtGui.QDialogButtonBox.Ok).click) self._timer_automatique.start(7000)
def __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 __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 __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 __init__(self, defered, automatique, parent, val_de): super(DDecisionB, self).__init__(parent) self._defered = defered self._automatique = automatique layout = QtGui.QVBoxLayout(self) self._widExplication = WExplication( text=texts_OL.get_text_explanation(pms.JOUEUR_B), parent=self, size=(450, 80)) layout.addWidget(self._widExplication) self._widMsgA = WMsgA(parent=self, automatique=self._automatique, val_de=val_de) layout.addWidget(self._widMsgA) self._widChoiceB = WChoiceB(parent=self) self._widChoiceB.setEnabled(False) layout.addWidget(self._widChoiceB) self._buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) self._buttons.accepted.connect(self._accept) self._buttons.setEnabled(False) layout.addWidget(self._buttons) self._set_connections() if self._automatique: self._timer = QtCore.QTimer() self._timer.timeout.connect( self._buttons.button(QtGui.QDialogButtonBox.Ok).click) self._timer.start(7000) self.setWindowTitle(le2mtrans(u"Decision")) self.adjustSize() self.setFixedSize(self.size())
def __init__(self, defered, automatique, parent, period, historique, remote): super(GuiDecision, self).__init__(parent) # variables self._defered = defered self._automatique = automatique self._historique = GuiHistorique(self, historique) self._remote = remote self._offer_items = {} layout = QtGui.QVBoxLayout(self) wperiod = WPeriod(period=period, ecran_historique=self._historique) layout.addWidget(wperiod) wexplanation = WExplication(text=texts_MC.get_text_explanation( self._remote.role, self._remote.value_or_cost), size=(450, 50), parent=self) layout.addWidget(wexplanation) self._compte_rebours = WCompterebours(parent=self, temps=pms.TEMPS, actionfin=self._accept) layout.addWidget(self._compte_rebours) gridlayout = QtGui.QGridLayout() layout.addLayout(gridlayout) CURRENT_LINE = 0 gridlayout.addWidget(QtGui.QLabel(u"Offres de ventes"), CURRENT_LINE, 0) gridlayout.addWidget(QtGui.QLabel(u"Offres d'achats"), CURRENT_LINE, 1) gridlayout.addWidget(QtGui.QLabel(u"Transactions"), CURRENT_LINE, 2) CURRENT_LINE += 1 self._model_ventes = QtGui.QStandardItemModel() self._listview_ventes = QtGui.QListView() self._listview_ventes.setModel(self._model_ventes) self._listview_ventes.setMaximumSize(300, 600) gridlayout.addWidget(self._listview_ventes, CURRENT_LINE, 0) self._model_achats = QtGui.QStandardItemModel() self._listview_achats = QtGui.QListView() self._listview_achats.setModel(self._model_achats) self._listview_achats.setMaximumSize(300, 600) gridlayout.addWidget(self._listview_achats, CURRENT_LINE, 1) self._listwidget_transactions = QtGui.QListWidget() self._listwidget_transactions.setMaximumSize(300, 600) gridlayout.addWidget(self._listwidget_transactions, CURRENT_LINE, 2) CURRENT_LINE += 1 if self._remote.role == pms.VENDEUR: self._layout_offer = QtGui.QHBoxLayout() self._layout_offer.addWidget(QtGui.QLabel(u"Offre de vente")) self._spin_offer = QtGui.QDoubleSpinBox() self._spin_offer.setDecimals(pms.DECIMALES) self._spin_offer.setMinimum(0) self._spin_offer.setMaximum(pms.DECISION_MAX) self._spin_offer.setButtonSymbols(QtGui.QSpinBox.NoButtons) self._spin_offer.setMaximumWidth(50) self._layout_offer.addWidget(self._spin_offer) self._button_send_offer = QtGui.QPushButton(u"Envoyer") self._button_send_offer.setMaximumWidth(100) self._button_send_offer.clicked.connect( lambda _: self._send_offer()) self._layout_offer.addWidget(self._button_send_offer) self._layout_offer.addSpacerItem( QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)) gridlayout.addLayout(self._layout_offer, CURRENT_LINE, 0) else: self._layout_offer = QtGui.QHBoxLayout() self._layout_offer.addWidget(QtGui.QLabel(u"Offre d'achat")) self._spin_offer = QtGui.QDoubleSpinBox() self._spin_offer.setDecimals(pms.DECIMALES) self._spin_offer.setMinimum(0) self._spin_offer.setMaximum(pms.DECISION_MAX) self._spin_offer.setButtonSymbols(QtGui.QSpinBox.NoButtons) self._spin_offer.setMaximumWidth(50) self._layout_offer.addWidget(self._spin_offer) self._button_send_offer = QtGui.QPushButton(u"Envoyer") self._button_send_offer.setMaximumWidth(100) self._button_send_offer.clicked.connect( lambda _: self._send_offer()) self._layout_offer.addWidget(self._button_send_offer) self._layout_offer.addSpacerItem( QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)) gridlayout.addLayout(self._layout_offer, CURRENT_LINE, 1) self.setWindowTitle(trans_MC(u"Marché")) self.adjustSize() self.setFixedSize(self.size()) if self._automatique: self._timer_automatique = QtCore.QTimer() self._timer_automatique.setSingleShot(False) self._timer_automatique.timeout.connect(self._play_auto) self._timer_automatique.start(5000)
def __init__(self, defered, automatique, parent): super(DQuestionnaire, self).__init__(parent) self.defered = defered self.automatique = automatique layout = QtGui.QVBoxLayout() self.setLayout(layout) self.wexplication = WExplication(parent=self, text=texts_PVQ.get_text_explanation(), size=(600, 50)) layout.addWidget(self.wexplication) gridlayout = QtGui.QGridLayout() layout.addLayout(gridlayout) label_q1 = QtGui.QLabel( u"D’après vous, par rapport à un niveau de prélèvement permettant " u"d’obtenir\nle meilleur gain du groupe, le niveau de prélèvement " u"de votre groupe était: ") gridlayout.addWidget(label_q1, 0, 0) self.radio_group_q1 = QtGui.QButtonGroup() hlayout_q1 = QtGui.QHBoxLayout() for k, v in sorted(pms.ECHELLE_ELEVE.items()): radio = QtGui.QRadioButton(v) self.radio_group_q1.addButton(radio, k) hlayout_q1.addWidget(radio) hlayout_q1.addSpacerItem( QtGui.QSpacerItem(20, 5, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)) gridlayout.addLayout(hlayout_q1, 0, 1) gridlayout.addWidget( QtGui.QLabel( u"Comment jugez-vous les actions des autres personnes de votre " u"groupe: "), 1, 0, 1, 2) hlayout_q2_1_label = QtGui.QHBoxLayout() hlayout_q2_1_label.addSpacerItem( QtGui.QSpacerItem(20, 5, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)) hlayout_q2_1_label.addWidget(QtGui.QLabel(u"Egoistes")) gridlayout.addLayout(hlayout_q2_1_label, 2, 0) self.radio_group_q2_1 = QtGui.QButtonGroup() hlayout_q2_1 = QtGui.QHBoxLayout() for k, v in sorted(pms.ECHELLE_ACCORD.items()): radio = QtGui.QRadioButton(v) self.radio_group_q2_1.addButton(radio, k) hlayout_q2_1.addWidget(radio) gridlayout.addLayout(hlayout_q2_1, 2, 1) hlayout_q2_2_label = QtGui.QHBoxLayout() hlayout_q2_2_label.addSpacerItem( QtGui.QSpacerItem(20, 5, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)) hlayout_q2_2_label.addWidget(QtGui.QLabel(u"Coopératives")) gridlayout.addLayout(hlayout_q2_2_label, 3, 0) self.radio_group_q2_2 = QtGui.QButtonGroup() hlayout_q2_2 = QtGui.QHBoxLayout() for k, v in sorted(pms.ECHELLE_ACCORD.items()): radio = QtGui.QRadioButton(v) self.radio_group_q2_2.addButton(radio, k) hlayout_q2_2.addWidget(radio) gridlayout.addLayout(hlayout_q2_2, 3, 1) gridlayout.addWidget( QtGui.QLabel( u"Vous attendiez-vous à un tel comportement de la part de votre " u"groupe?"), 4, 0) self.radio_group_q3 = QtGui.QButtonGroup() hlayout_q3 = QtGui.QHBoxLayout() for k, v in sorted(pms.OUI_NON.items()): radio = QtGui.QRadioButton(v) self.radio_group_q3.addButton(radio, k) hlayout_q3.addWidget(radio) hlayout_q3.addSpacerItem( QtGui.QSpacerItem(20, 5, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)) gridlayout.addLayout(hlayout_q3, 4, 1) gridlayout.addWidget( QtGui.QLabel( u"Quel est d’après vous le niveau de prélèvement individuel " u"qui, s’il \nétait respecté par les 5 personnes du " u"groupe, permettrait d’obtenir \nle gain du groupe maximum?"), 5, 0) self.radio_group_q4 = QtGui.QButtonGroup() hlayout_q4 = QtGui.QHBoxLayout() for k, v in sorted(pms.NE_SAIT_PAS_ENVIRON.items()): radio = QtGui.QRadioButton(v) self.radio_group_q4.addButton(radio, k) hlayout_q4.addWidget(radio) self.spinbox_estimation = QtGui.QSpinBox() self.spinbox_estimation.setMinimum(0) self.spinbox_estimation.setButtonSymbols(QtGui.QSpinBox.NoButtons) self.spinbox_estimation.setFixedWidth(30) self.spinbox_estimation.setEnabled(False) self.radio_group_q4.button(pms.ENVIRON).toggled.connect( self.spinbox_estimation.setEnabled) hlayout_q4.addWidget(self.spinbox_estimation) hlayout_q4.addSpacerItem( QtGui.QSpacerItem(20, 5, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)) gridlayout.addLayout(hlayout_q4, 5, 1) buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) buttons.accepted.connect(self.accept) layout.addWidget(buttons) if self.automatique: self.radio_group_q1.button(random.choice( pms.ECHELLE_ELEVE.keys())).click() self.radio_group_q2_1.button( random.choice(pms.ECHELLE_ACCORD.keys())).click() self.radio_group_q2_2.button( random.choice(pms.ECHELLE_ACCORD.keys())).click() self.radio_group_q3.button(random.choice( pms.OUI_NON.keys())).click() self.radio_group_q4.button( random.choice(pms.NE_SAIT_PAS_ENVIRON.keys())).click() if self.radio_group_q4.checkedId() == pms.ENVIRON: self.spinbox_estimation.setValue(random.randint(0, 30)) self.timer = QtCore.QTimer() self.timer.timeout.connect(self.accept) self.timer.start(7000)
def __init__(self, remote, defered, automatique, parent, period, historique, summary_text, triangle_transactions, star_transactions): """ :param defered: :param automatique: :param parent: :param period: :param historique: :param summary_text: :param history_screen: :param size_histo: the size of the history table. The width of the explanation area will be the same than the width of the history table :return: """ super(GuiRecapitulatif, self).__init__(parent) self._remote = remote self._defered = defered self._automatique = automatique layout = QtGui.QVBoxLayout(self) # period label and history button -------------------------------------- self.ecran_historique = GuiHistorique( self, historique, size=SIZE_HISTO) layout_period = QtGui.QHBoxLayout() label_period = QtGui.QLabel(le2mtrans("Period") + " {}".format(period)) layout_period.addWidget(label_period) layout_period.addSpacerItem( QtGui.QSpacerItem(20, 5, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)) button_history = QtGui.QPushButton(le2mtrans("History")) button_history.clicked.connect(self.ecran_historique.show) layout_period.addWidget(button_history) layout.addLayout(layout_period) # timer self._compte_rebours = WCompterebours( parent=self, temps=pms.SUMMARY_TIME, actionfin=self._display_warning) layout.addWidget(self._compte_rebours) # explanation zone ----------------------------------------------------- self.widexplication = WExplication(text=summary_text, parent=self, size=(SIZE_HISTO[0], 80)) layout.addWidget(self.widexplication) # transactions --------------------------------------------------------- try: max_triangle_price = max(triangle_transactions.MRI_trans_price) except ValueError: # no transaction max_triangle_price = 1 try: max_star_price = max(star_transactions.MRI_trans_price) except ValueError: max_star_price = 1 max_price = max(max_triangle_price, max_star_price) transactions_layout = QtGui.QGridLayout() layout.addLayout(transactions_layout) # triangle --- triangle_label = QtGui.QLabel(trans_MRI(u"Triangle")) triangle_label.setStyleSheet("font-weight: bold;") transactions_layout.addWidget(triangle_label, 0, 0) self._triangle_transaction_zone = TransactionZone(zone_size=(450, 250)) try: for i, item in triangle_transactions.iterrows(): price = item.MRI_trans_price buyer = item.MRI_trans_buyer seller = item.MRI_trans_seller implied, buyer_or_seller = False, None if buyer == self._remote.le2mclt.uid or \ seller == self._remote.le2mclt.uid: implied = True buyer_or_seller = pms.BUYER if \ buyer == self._remote.le2mclt.uid else pms.SELLER color = "blue" if implied else "black" self._triangle_transaction_zone.add_transaction( price, buyer_or_seller, color) except ValueError: # no transactions pass transactions_layout.addWidget(self._triangle_transaction_zone, 1, 0) self._triangle_transactions_graph = GraphicalZone( triangle_transactions, max_price, pms.TRIANGLE, zone_size=(450, 250)) transactions_layout.addWidget(self._triangle_transactions_graph, 2, 0) # star --- star_label = QtGui.QLabel(trans_MRI(u"Star")) star_label.setStyleSheet("font-weight: bold;") transactions_layout.addWidget(star_label, 0, 2) self._star_transaction_zone = TransactionZone(zone_size=(450, 250)) try: for i, item in star_transactions.iterrows(): price = item.MRI_trans_price buyer = item.MRI_trans_buyer seller = item.MRI_trans_seller implied, buyer_or_seller = False, None if buyer == self._remote.le2mclt.uid or \ seller == self._remote.le2mclt.uid: implied = True buyer_or_seller = pms.BUYER if \ buyer == self._remote.le2mclt.uid else pms.SELLER color = "blue" if implied else "black" self._star_transaction_zone.add_transaction( price, buyer_or_seller, color) except ValueError: # no transactions pass transactions_layout.addWidget(self._star_transaction_zone, 1, 2) self._star_transactions_graph = GraphicalZone( star_transactions, max_price, pms.STAR, zone_size=(450, 250)) transactions_layout.addWidget(self._star_transactions_graph, 2, 2) separator = QtGui.QFrame() separator.setFrameShape(QtGui.QFrame.VLine) transactions_layout.addWidget( separator, 0, 1, transactions_layout.rowCount(), 1) # history table -------------------------------------------------------- # in this screen we only keep the header and the last line of the # history histo_recap = [historique[0], historique[-1]] self.tablemodel = TableModelHistorique(histo_recap) self.widtableview = WTableview(parent=self, tablemodel=self.tablemodel, size=(SIZE_HISTO[0], 100)) self.widtableview.ui.tableView.verticalHeader().setResizeMode( QtGui.QHeaderView.Stretch) layout.addWidget(self.widtableview) buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) buttons.accepted.connect(self._accept) layout.addWidget(buttons) # automatique if self._automatique: self._timer_automatique = QtCore.QTimer() self._timer_automatique.timeout.connect( buttons.button(QtGui.QDialogButtonBox.Ok).click) self._timer_automatique.start(7000) # taille et titre self.setWindowTitle(le2mtrans(u"Summary"))
def __init__(self, defered, automatique, parent, period, historique, remote): super(GuiDecision, self).__init__(parent) # variables self._defered = defered self._automatique = automatique self._remote = remote layout = QtGui.QVBoxLayout(self) self._historique = GuiHistorique(self, historique, size=SIZE_HISTO) wperiod = WPeriod( period=period, ecran_historique=self._historique) layout.addWidget(wperiod) wexplanation = WExplication( text=texts_MRI.get_text_explanation( self._remote.balance_if_triangle, self._remote.balance_if_star), size=(SIZE_HISTO[0], 70), parent=self) layout.addWidget(wexplanation) # Compte à rebours ===================================================== self._compte_rebours = WCompterebours( parent=self, temps=pms.MARKET_TIME, actionfin=self._accept) self._compte_rebours.setStyleSheet("color: blue;") layout.addWidget(self._compte_rebours) # zone information actualisée ========================================== self._information = InformationZone() layout.addWidget(self._information) # market =============================================================== market_layout = QtGui.QGridLayout() layout.addLayout(market_layout) # triangle triangle_label = QtGui.QLabel(trans_MRI(u"Triangle")) triangle_label.setStyleSheet("color: red;") market_layout.addWidget(triangle_label, 0, 0, 1, 2) self._triangle_purchase_zone = OfferZone(pms.BUY, zone_size=(350, 250)) market_layout.addWidget(self._triangle_purchase_zone, 1, 0) self._triangle_sell_zone = OfferZone(pms.SELL, zone_size=(350, 250)) market_layout.addWidget(self._triangle_sell_zone, 1, 1) self._triangle_transactions = TransactionZone(zone_size=(350, 250)) market_layout.addWidget(self._triangle_transactions, 2, 0, 1, 2) # star star_label = QtGui.QLabel(trans_MRI(u"Star")) star_label.setStyleSheet("color: red;") market_layout.addWidget(star_label, 0, 3, 1, 2) self._star_purchase_zone = OfferZone(pms.BUY, zone_size=(350, 250)) market_layout.addWidget(self._star_purchase_zone, 1, 3) self._star_sell_zone = OfferZone(pms.SELL, zone_size=(350, 250)) market_layout.addWidget(self._star_sell_zone, 1, 4) self._star_transactions = TransactionZone(zone_size=(350, 250)) market_layout.addWidget(self._star_transactions, 2, 3, 1, 2) separator = QtGui.QFrame() separator.setFrameShape(QtGui.QFrame.VLine) market_layout.addWidget(separator, 0, 2, market_layout.rowCount(), 1) # finalisation ========================================================= layout.addSpacing(50) self._make_connections() self.setWindowTitle(trans_MRI(u"Market")) # self.adjustSize() # self.setFixedSize(self.size()) if self._automatique: self._timer_automatique = QtCore.QTimer() self._timer_automatique.timeout.connect(self._play_auto) self._timer_automatique.start(randint(2000, 7000))
def __init__(self, defered, automatique, parent): super(DQuestionnaireInformation, self).__init__(parent) self.defered = defered self.automatique = automatique layout = QtGui.QVBoxLayout() self.setLayout(layout) self.wexplication = WExplication( parent=self, text=texts_PVQI.get_text_explanation(), size=(600, 50)) layout.addWidget(self.wexplication) gridlayout = QtGui.QGridLayout() layout.addLayout(gridlayout) label_q1 = QtGui.QLabel( u"L’affichage des prélèvements a-t-il modifié votre prélèvement ?") gridlayout.addWidget(label_q1, 0, 0) self.radio_group_q1 = QtGui.QButtonGroup() hlayout_q1 = QtGui.QHBoxLayout() for k, v in sorted(pms.ECHELLE_AUGMENTATION.items()): radio = QtGui.QRadioButton(v) self.radio_group_q1.addButton(radio, k) hlayout_q1.addWidget(radio) hlayout_q1.addSpacerItem( QtGui.QSpacerItem(20, 5, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)) gridlayout.addLayout(hlayout_q1, 0, 1) gridlayout.addWidget(QtGui.QLabel(u"Quelles en sont les raisons? "), 1, 0, 1, 2) self.enonces = [ u"Je souhaitais avoir le même niveau de prélèvement que les autres", u"Je souhaitais augmenter mon gain", u"Je souhaitais diminuer les coûts de prélèvement", u"Le groupe a augmenté son prélèvement, j’ai dû diminuer mon \n" u"prélèvement de façon à limiter la perte de gains" ] row_number = 2 self.group_buttons = list() hlayouts = list() for i, e in enumerate(self.enonces): gridlayout.addWidget(QtGui.QLabel(e), row_number + i, 0) self.group_buttons.append(QtGui.QButtonGroup()) hlayouts.append(QtGui.QHBoxLayout()) for k, v in sorted(pms.ECHELLE_ACCORD.items()): radio = QtGui.QRadioButton(v) self.group_buttons[-1].addButton(radio, k) hlayouts[-1].addWidget(radio) hlayouts[-1].addSpacerItem( QtGui.QSpacerItem(20, 5, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)) gridlayout.addLayout(hlayouts[-1], row_number + i, 1) row_number = gridlayout.rowCount() hlayout_autre = QtGui.QHBoxLayout() hlayout_autre.addSpacerItem( QtGui.QSpacerItem(20, 5, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)) hlayout_autre.addWidget(QtGui.QLabel(u"Autre")) gridlayout.addLayout(hlayout_autre, row_number, 0) self.text_edit = QtGui.QTextEdit() self.text_edit.setFixedSize(600, 100) gridlayout.addWidget(self.text_edit, row_number, 1) buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) buttons.accepted.connect(self.accept) layout.addWidget(buttons) if self.automatique: self.radio_group_q1.button( random.choice(pms.ECHELLE_AUGMENTATION.keys())).click() for gb in self.group_buttons: gb.button(random.choice(pms.ECHELLE_ACCORD.keys())).click() self.text_edit.setText(u"Texte automatique") self.timer = QtCore.QTimer() self.timer.timeout.connect(self.accept) self.timer.start(7000)
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, size=(1100, 500)) layout = QtGui.QVBoxLayout(self) wperiod = WPeriod(period=periode, ecran_historique=self._historique, parent=self) layout.addWidget(wperiod) wexplanation = WExplication( text=textes_PGLG.get_text_explanation(), parent=self, size=(450, 80)) layout.addWidget(wexplanation) gridlayout = QtGui.QGridLayout() layout.addLayout(gridlayout) CURRENT_LINE = 0 gridlayout.addWidget(QtGui.QLabel(u"Saisissez le nombre de jetons que " u"vous placez sur votre compte individuel"), CURRENT_LINE, 0) self._spin_indiv = QtGui.QSpinBox() self._spin_indiv.setMinimum(0) self._spin_indiv.setMaximum(pms.DOTATION) self._spin_indiv.setSingleStep(1) self._spin_indiv.setButtonSymbols(QtGui.QSpinBox.NoButtons) self._spin_indiv.setMaximumWidth(80) gridlayout.addWidget(self._spin_indiv, CURRENT_LINE, 1) CURRENT_LINE += 1 gridlayout.addWidget(QtGui.QLabel(u"Saisissez le nombre de jetons que " u"vous placez sur le compte local"), CURRENT_LINE, 0) self._spin_local = QtGui.QSpinBox() self._spin_local.setMinimum(0) self._spin_local.setMaximum(pms.DOTATION) self._spin_local.setSingleStep(1) self._spin_local.setButtonSymbols(QtGui.QSpinBox.NoButtons) self._spin_local.setMaximumWidth(80) gridlayout.addWidget(self._spin_local, CURRENT_LINE, 1) CURRENT_LINE += 1 gridlayout.addWidget(QtGui.QLabel(u"Saisissez le nombre de jetons que " u"vous placez sur le compte global"), CURRENT_LINE, 0) self._spin_global = QtGui.QSpinBox() self._spin_global.setMinimum(0) self._spin_global.setMaximum(pms.DOTATION) self._spin_global.setSingleStep(1) self._spin_global.setButtonSymbols(QtGui.QSpinBox.NoButtons) self._spin_global.setMaximumWidth(80) gridlayout.addWidget(self._spin_global, CURRENT_LINE, 1) buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) buttons.accepted.connect(self._accept) layout.addWidget(buttons) self.setWindowTitle(trans_PGLG(u"Decision")) self.adjustSize() self.setFixedSize(self.size()) if self._automatique: indiv, loc, glob = 0, 0, 0 while indiv + loc + glob != pms.DOTATION: indiv = randint(0, pms.DOTATION) loc = randint(0, pms.DOTATION) glob = randint(0, pms.DOTATION) self._spin_indiv.setValue(indiv) self._spin_local.setValue(loc) self._spin_global.setValue(glob) self._timer_automatique = QtCore.QTimer() self._timer_automatique.timeout.connect( buttons.button(QtGui.QDialogButtonBox.Ok).click) self._timer_automatique.start(7000)