本文整理汇总了Python中util.utili18n.le2mtrans函数的典型用法代码示例。如果您正苦于以下问题:Python le2mtrans函数的具体用法?Python le2mtrans怎么用?Python le2mtrans使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了le2mtrans函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: finalize_part
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")
示例2: _accept
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)
示例3: display_payoffs_onserver
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()
示例4: __init__
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())
示例5: _accept
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()
示例6: _headtail
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"))))
示例7: __init__
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)
示例8: _print
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'>{}€</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)
示例9: _stoprepetitions
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 "))
示例10: _display_questfinal
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"
)
)
示例11: _load_questcomp
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)))
示例12: remove_wait_mode
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)
示例13: __init__
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())
示例14: _accept
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
示例15: __init__
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)