Debian Codegraph @

wxgeometrie/modules/calculatrice/__init__.py

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2
3 ##--------------------------------------#######
4 # Calculatrice #
5 ##--------------------------------------#######
6 # WxGeometrie
7 # Dynamic geometry, graph plotter, and more for french mathematic teachers.
8 # Copyright (C) 2005-2013 Nicolas Pourcelot
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
14 #
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
24 from functools import partial
25
26 from PyQt5.QtGui import QIcon, QCursor, QTextCursor
27 from PyQt5.QtWidgets import QCheckBox, QPushButton, QTextEdit, QMenu, QLabel, \
28 QSpinBox, QToolButton, QWidget, QTabWidget, QGroupBox, QComboBox, \
29 QLineEdit, QHBoxLayout, QVBoxLayout
30 from PyQt5.QtCore import Qt
31
32 from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
33 from matplotlib.figure import Figure
34
35 from ...GUI.ligne_commande import LigneCommande
36 from ...GUI.qtlib import png
37 from ...GUI.inspecteur import FenCode
38 from ...GUI.menu import MenuBar
39 from ...GUI.panel import Panel_simple
40 from ...mathlib.interprete import Interprete
41 from ...mathlib.parsers import latex2mathtext
42 from ...mathlib.end_user_functions import __classement__
43
44 from ...pylib import print_error, debug, no_argument, eval_safe
45 from ... import param
46
47
48 class CalculatriceMenuBar(MenuBar):
49 def __init__(self, panel):
50 MenuBar.__init__(self, panel)
51 self.ajouter("Fichier", ["Réinitialiser",
52 "Réinitialiser la calculatrice.", "Ctrl+N",
53 self.panel.initialiser],
54 ["ouvrir"], ["enregistrer"],
55 ["enregistrer_sous"], ['session'], None, ["quitter"])
56 self.ajouter("Affichage", ["onglet"], ["plein_ecran"])
57 for rubrique in __classement__:
58 self.ajouter(rubrique, *(self.formater(contenu, rubrique != "Symboles") for contenu in __classement__[rubrique]))
59 # pas de parenthese apres un symbole
60 self.ajouter("Outils",
61 ["Mémoriser le résultat", "Copie le resultat du calcul dans le presse-papier, afin de pouvoir l'utiliser ailleurs.", "Ctrl+M", self.panel.vers_presse_papier],
62 ["options"],
63 )
64 self.ajouter("Avancé",
65 ["État interne de l'interprète", "État de l'interprète de commandes.", "Ctrl+H", self.panel.EtatInterne],
66 ["ligne_commande"],
67 ["debug"],
68 )
69 self.ajouter("?")
70
71
72 def formater(self, contenu, parentheses = True):
73 if contenu is None:
74 return
75 titre, nom, doc = contenu
76 return [titre, doc, "", partial(self.panel.insere, nom=nom, parentheses=parentheses)]
77
78
79
80 class BoutonValider(QToolButton):
81
82 modes = [('exact', 'résultats exacts'), ('approche', 'résultats approchés'),
83 ('scientifique', 'résultats en écriture scientifique')]
84
85 def __init__(self, parent):
86 QToolButton.__init__(self)
87 self.parent = parent
88 self.setAutoRaise(True)
89 self.mode_normal()
90
91 self.menu = menu = QMenu(self)
92 self.setMenu(menu)
93 for mode, titre in self.modes:
94 nom = 'mode_' + mode
95 action = menu.addAction(QIcon(png(nom)), titre)
96 action.setIconVisibleInMenu(True)
97 action.triggered.connect(getattr(self, nom))
98 self.clicked.connect(self.mode_occupe)
99
100
101 def _set_icon(self, nom):
102 pix = png(nom)
103 self.setIcon(QIcon(pix))
104 self.setIconSize(pix.size())
105
106 def mode_exact(self, *args):
107 self._set_icon('mode_exact_')
108 self.parent.param("calcul_exact", True)
109 self.parent.param("ecriture_scientifique", False)
110
111 def mode_approche(self, *args):
112 self._set_icon('mode_approche_')
113 self.parent.param("calcul_exact", False)
114 self.parent.param("ecriture_scientifique", False)
115
116 def mode_scientifique(self, *args):
117 self._set_icon('mode_scientifique_')
118 self.parent.param("calcul_exact", False)
119 self.parent.param("ecriture_scientifique", True)
120
121 def mode_occupe(self):
122 self._set_icon('thinking2_')
123
124 def mode_normal(self):
125 if self.parent.param("calcul_exact"):
126 self.mode_exact()
127 elif self.parent.param("ecriture_scientifique"):
128 self.mode_scientifique()
129 else:
130 self.mode_approche()
131
132
133
134 class PaveNumerique(QWidget):
135 def __init__(self, parent):
136 QWidget.__init__(self, parent)
137 self.parent = parent
138 ### Pave numerique de la calculatrice ###
139 # On construit le pavé de la calculatrice.
140 # Chaque bouton du pavé doit provoquer l'insertion de la commande correspondante.
141
142 self.pave = pave = QVBoxLayout()
143 # pave.setSpacing(1)
144 boutons = ["2nde", "ans", "ouv", "ferm", "egal", "7", "8", "9", "div", "x", "4", "5", "6", "mul", "y", "1", "2", "3", "minus", "z", "0", "pt", "pow", "plus", "t", "rac", "sin", "cos", "tan", "exp", "i", "pi", "e", "abs", "mod"]
145 inserer = ["", "ans()", "(", ")", "=", "7", "8", "9", "/", "x", "4", "5", "6", "*", "y", "1", "2", "3", "-", "z", "0", ".", "^", "+", "t", "sqrt(", ("sin(", "asin(", "sinus / arcsinus"), ("cos(", "acos(", "cosinus / arccosinus"), ("tan(", "atan(", "tangente / arctangente"), ("exp(", "ln(", "exponentielle / logarithme neperien"), ("i", "cbrt(", "i / racine cubique"), ("pi", "sinh(", "pi / sinus hyperbolique"), ("e", "cosh", "e / cosinus hyperbolique"), ("abs(", "tanh", "valeur absolue / tangente hyperbolique"), (" mod ", "log10(", "modulo / logarithme decimal")]
146
147 self.seconde = False # indique si la touche 2nde est activee.
148
149 self.actions = [self.touche_2nde]
150
151 for i, nom_bouton in enumerate(boutons):
152 # On aligne les boutons de la calculatrice par rangées de 5.
153 if i%5 == 0:
154 self.rangee = rangee = QHBoxLayout()
155 rangee.addStretch(1)
156 pave.addLayout(rangee)
157
158 # Ensuite, on construit une liste de fonctions, parallèlement à la liste des boutons.
159 if i > 0:
160 self.actions.append(partial(self.action, commande=inserer[i]))
161
162 bouton = QPushButton()
163 pix = png('btn_' + nom_bouton)
164 bouton.setIcon(QIcon(pix))
165 bouton.setIconSize(pix.size())
166 bouton.setFlat(True)
167 # bouton.SetBackgroundColour(self.GetBackgroundColour())
168 rangee.addWidget(bouton)
169 if i%5 == 4:
170 rangee.addStretch(2)
171 # A chaque bouton, on associe une fonction de la liste.
172 bouton.clicked.connect(self.actions[i])
173 if type(inserer[i]) == tuple:
174 bouton.setToolTip(inserer[i][2])
175
176 self.setLayout(self.pave)
177
178 def touche_2nde(self, event=None):
179 self.seconde = not self.seconde
180 if self.seconde:
181 self.message("Touche [2nde] activée.")
182 else:
183 self.message("")
184
185 def action(self, event=None, commande=''):
186 entree = self.parent.entree
187 if type(commande) == tuple:
188 entree.insert(commande[self.seconde])
189 else:
190 entree.insert(commande)
191 n = entree.cursorPosition()
192 entree.setFocus()
193 entree.setCursorPosition(n)
194 self.seconde = False
195 self.parent.message("")
196
197
198
199 class Options(QWidget):
200 def __init__(self, parent):
201 QWidget.__init__(self, parent)
202 self.parent = parent
203 prm = parent.param
204
205 self.ensembles = ('R', 'C')
206
207 ### Liste des options de la calculatrice ###
208 self.pave = QVBoxLayout()
209
210 # Chiffres significatifs
211 box = QGroupBox("Mode calcul approché")
212 box_layout = QVBoxLayout()
213 box.setLayout(box_layout)
214
215 ligne = QHBoxLayout()
216 box_layout.addLayout(ligne)
217 ligne.addWidget(QLabel("Afficher "))
218 self.sc_precision_affichage = sc = QSpinBox(self)
219 # param.precision_calcul = 60 par défaut
220 sc.setRange(1, 50)
221 sc.setValue(prm("precision_affichage"))
222 sc.valueChanged.connect(self.EvtPrecisionAffichage)
223 ligne.addWidget(sc)
224 ligne.addWidget(QLabel(" chiffre(s) significatif(s)."))
225 ligne.addStretch()
226
227 self.pave.addWidget(box)
228
229 # Nombre de décimales
230 box = QGroupBox("Mode écriture scientifique")
231 box_layout = QVBoxLayout()
232 box.setLayout(box_layout)
233
234 ligne = QHBoxLayout()
235 box_layout.addLayout(ligne)
236 ligne.addWidget(QLabel("Arrondir les résultats à "))
237 self.sc_decimales = sc = QSpinBox(self)
238 sc.setRange(0, 11)
239 sc.setValue(prm("ecriture_scientifique_decimales"))
240 sc.valueChanged.connect(self.EvtDecimales)
241 ligne.addWidget(sc)
242 ligne.addWidget(QLabel(" décimale(s)."))
243 ligne.addStretch()
244
245 self.pave.addWidget(box)
246
247 box = QGroupBox("Copie Automatique")
248 box_layout = QVBoxLayout()
249 box.setLayout(box_layout)
250 # Copie du résultat dans le presse-papier
251 ligne = QHBoxLayout()
252 box_layout.addLayout(ligne)
253 self.cb_copie_automatique = cb = QCheckBox(self)
254 cb.setChecked(prm("copie_automatique"))
255 cb.stateChanged.connect(self.EvtCopieAutomatique)
256 cb.setToolTip("Copier automatiquement le résultat du calcul dans le presse-papier.")
257 ligne.addWidget(cb)
258 ligne.addWidget(QLabel("Copie du résultat dans le presse-papier."))
259 ligne.addStretch()
260
261 # En mode LaTeX
262 ligne = QHBoxLayout()
263 box_layout.addLayout(ligne)
264 self.cb_copie_automatique_LaTeX = cb = QCheckBox(self)
265 cb.setChecked(prm("copie_automatique_LaTeX"))
266 cb.setToolTip("Copier le résultat du calcul au format LaTeX dans le presse-papier.")
267 ligne.addWidget(cb)
268 cb.stateChanged.connect(self.EvtCopieAutomatiqueLatex)
269 self.st_copie_automatique_LaTeX = st = QLabel("Copie au format LaTeX (si possible).")
270 ligne.addWidget(st)
271 ligne.addStretch()
272
273 self.pave.addWidget(box)
274 #~ self.pave.addStretch()
275
276 box = QGroupBox("Ensemble de résolution")
277 box_layout = QVBoxLayout()
278 box.setLayout(box_layout)
279 ligne = QHBoxLayout()
280 box_layout.addLayout(ligne)
281 ligne.addWidget(QLabel('Résoudre et factoriser dans '))
282 self.cb_ensemble = cb = QComboBox()
283 ligne.addWidget(cb)
284 cb.addItems(('R (réels)', 'C (complexes)'))
285 cb.setCurrentIndex(self.ensembles.index(prm('ensemble')))
286 cb.currentIndexChanged.connect(self.EvtEnsemble)
287 self.pave.addWidget(box)
288 self.pave.addStretch()
289
290 self.setLayout(self.pave)
291 # Pour (dés)activer la ligne "Copie au format LaTeX" au besoin.
292 self.EvtCopieAutomatique()
293
294 def EvtPrecisionAffichage(self, event=None):
295 val = self.sc_precision_affichage.value()
296 self.parent.param("precision_affichage", val)
297
298
299 def EvtDecimales(self, event=None):
300 val = self.sc_decimales.value()
301 self.parent.param("ecriture_scientifique_decimales", val)
302
303
304 def EvtCopieAutomatique(self, event=None):
305 valeur = self.cb_copie_automatique.isChecked()
306 self.parent.param("copie_automatique", valeur)
307 if valeur:
308 self.cb_copie_automatique_LaTeX.setEnabled(True)
309 self.st_copie_automatique_LaTeX.setEnabled(True)
310 else:
311 self.cb_copie_automatique_LaTeX.setEnabled(False)
312 self.st_copie_automatique_LaTeX.setEnabled(False)
313
314
315 def EvtCopieAutomatiqueLatex(self, event=None):
316 val = self.cb_copie_automatique_LaTeX.isChecked()
317 self.parent.param("copie_automatique_LaTeX", val)
318
319
320 def EvtEnsemble(self, index):
321 self.parent.param("ensemble", self.ensembles[index])
322
323
324
325 class Avance(QWidget):
326 def __init__(self, parent):
327 QWidget.__init__(self, parent)
328 self.parent = parent
329 prm = parent.param
330
331
332 ### Liste des options avancées de la calculatrice ###
333 self.pave = QVBoxLayout()
334
335 box = QGroupBox("Post-traitement")
336 box_layout = QVBoxLayout()
337 box.setLayout(box_layout)
338 box_layout.addWidget(QLabel("Traitement automatiquement du résultat :"))
339 self.traitement = QLineEdit()
340 traitement = self.parent.param("appliquer_au_resultat") or '_'
341 self.traitement.setText(traitement)
342 self.traitement.setMinimumWidth(100)
343 self.traitement.setToolTip("Fonction ou opérations à appliquer automatiquement au résultat (représenté par _). Ex: 'factoriser(_)'.")
344 self.traitement.editingFinished.connect(self.EvtAppliquerResultat)
345 box_layout.addWidget(self.traitement)
346 self.pave.addWidget(box)
347 self.setLayout(self.pave)
348 self.pave.addStretch()
349
350
351 def EvtAppliquerResultat(self, event=None):
352 val = self.traitement.text().strip()
353 if not val:
354 self.traitement.setText('_')
355 val = None
356 elif val == '_':
357 val = None
358 self.parent.param("appliquer_au_resultat", val)
359
360
361
362
363 class OngletsCalc(QTabWidget):
364 def __init__(self, parent):
365 QTabWidget.__init__(self, parent)
366 self.addTab(PaveNumerique(parent), ' Pavé numérique ')
367 self.addTab(Options(parent), 'Options')
368 self.addTab(Avance(parent), 'Avancé')
369 self.setTabPosition(QTabWidget.South)
370 self.setStyleSheet("""
371 QTabBar::tab:selected {
372 background: white;
373 border: 1px solid #C4C4C3;
374 border-top-color: white; /* same as the pane color */
375 border-bottom-left-radius: 4px;
376 border-bottom-right-radius: 4px;
377 border-top-left-radius: 0px;
378 border-top-right-radius: 0px;
379 min-width: 8ex;
380 padding: 7px;
381 }
382 QStackedWidget {background:white}
383 QTabBar QToolButton {
384 background:white;
385 border: 1px solid #C4C4C3;
386 border-top-color: white; /* same as the pane color */
387 border-bottom-left-radius: 4px;
388 border-bottom-right-radius: 4px;
389 border-top-left-radius: 0px;
390 border-top-right-radius: 0px;
391 }
392 """)
393
394
395
396
397
398 class Calculatrice(Panel_simple):
399 titre = "Calculatrice" # Donner un titre a chaque module
400
401 def __init__(self, *args, **kw):
402 Panel_simple.__init__(self, *args, **kw)
403 self.interprete = Interprete(calcul_exact = self.param("calcul_exact"),
404 ecriture_scientifique = self.param("ecriture_scientifique"),
405 formatage_OOo = self.param("formatage_OOo"),
406 formatage_LaTeX = self.param("formatage_LaTeX"),
407 ecriture_scientifique_decimales = self.param("ecriture_scientifique_decimales"),
408 precision_calcul = self.param("precision_calcul"),
409 precision_affichage = self.param("precision_affichage"),
410 appliquer_au_resultat = self.param('appliquer_au_resultat'),
411 simpify = True,
412 ensemble=self.param('ensemble'),
413 )
414
415 bouton = BoutonValider(self)
416 bouton.setToolTip("Laissez appuyé pour changer de mode.")
417 self.entree = entree = LigneCommande(self, longueur=550,
418 action=self.affichage_resultat, bouton=bouton)
419 entree.setToolTip("[Maj]+[Entrée] pour une valeur approchée.")
420 self.entree.texte.setContextMenuPolicy(Qt.CustomContextMenu)
421 self.entree.texte.customContextMenuRequested.connect(self.EvtMenu)
422
423
424 self.sizer = sizer = QVBoxLayout()
425 sizer.addWidget(entree)
426 self.corps = corps = QHBoxLayout()
427 sizer.addLayout(corps)
428 self.resultats = resultats = QTextEdit(self)
429 resultats.setMinimumSize(450, 310)
430 resultats.setReadOnly(True)
431 corps.addWidget(resultats, 1)
432 onglets = OngletsCalc(self)
433 corps.addWidget(onglets)
434 onglets.setCurrentIndex(self.param('onglet'))
435 onglets.currentChanged.connect(self.EvtCurrentChanged)
436
437 self.figure = Figure(figsize=(5,1.3), frameon=True, facecolor="w")
438 self.visualisation = FigureCanvas(self.figure)
439 self.axes = axes = self.figure.add_axes([0, 0, 1, 1], frameon=False)
440 axes.axison = False
441 self.pp_texte = axes.text(0.5, 0.5, "", horizontalalignment='center',
442 verticalalignment='center', transform = axes.transAxes, size=18)
443 self.visualisation.setContextMenuPolicy(Qt.CustomContextMenu)
444 self.visualisation.customContextMenuRequested.connect(self.EvtMenuVisualisation)
445 sizer.addWidget(self.visualisation)
446
447 self.setLayout(self.sizer)
448 self.initialiser()
449
450
451 def activer(self):
452 Panel_simple.activer(self)
453 # Actions à effectuer lorsque l'onglet devient actif
454 self.entree.setFocus()
455
456
457 def _sauvegarder(self, fgeo):
458 fgeo.contenu["Calculatrice"] = [{}]
459 fgeo.contenu["Calculatrice"][0]["Historique"] = [repr(self.entree.historique)]
460 fgeo.contenu["Calculatrice"][0]["Affichage"] = [self.resultats.toPlainText()]
461 fgeo.contenu["Calculatrice"][0]["Etat_interne"] = [self.interprete.save_state()]
462
463
464
465 def _ouvrir(self, fgeo):
466 if "Calculatrice" in fgeo.contenu:
467 calc = fgeo.contenu["Calculatrice"][0]
468 self.initialiser()
469
470 self.entree.historique = eval_safe(calc["Historique"][0])
471 resultats = calc["Affichage"][0]
472 if resultats:
473 resultats += '\n\n'
474 self.resultats.setPlainText(resultats)
475 self.resultats.moveCursor(QTextCursor.End)
476 self.interprete.load_state(calc["Etat_interne"][0])
477
478
479 def modifier_pp_texte(self, chaine):
480 """Modifier le résultat affiché en LaTeX (pretty print)."""
481 if self.param("latex"):
482 # On utilise directement LaTeX pour le rendu
483 chaine = "$" + chaine + "$"
484 else:
485 # On utilise le parser matplotlib.mathtext, moins complet mais bien
486 # plus rapide. Certaines adaptations doivent être faites.
487 chaine = latex2mathtext(chaine)
488 self.pp_texte.set_text(chaine)
489 self.visualisation.draw()
490
491 def vers_presse_papier(self, event = None, texte = None):
492 if texte is None:
493 texte = self.dernier_resultat
494 Panel_simple.vers_presse_papier(texte)
495
496 def copier_latex(self, event = None):
497 self.vers_presse_papier(texte = self.interprete.latex_dernier_resultat.strip("$"))
498
499 def initialiser(self, event = None):
500 self.dernier_resultat = "" # dernier resultat, sous forme de chaine formatee pour l'affichage
501 self.entree.initialiser()
502 self.interprete.initialiser()
503 self.resultats.clear()
504
505 def affichage_resultat(self, commande, **kw):
506 # Commandes spéciales:
507 if commande in ('clear', 'clear()', 'efface', 'efface()'):
508 self.initialiser()
509 self.modifier_pp_texte("Calculatrice réinitialisée.")
510 return
511
512 self.modifie = True
513 try:
514 try:
515 ##self.parent.parent.application.processEvents()
516 if kw.get("shift"):
517 self.interprete.calcul_exact = False
518 resultat, latex = self.interprete.evaluer(commande)
519 if latex == "$?$": # provoque une erreur (matplotlib 0.99.1.1)
520 latex = "Désolé, je ne sais pas faire..."
521 finally:
522 self.interprete.calcul_exact = self.param('calcul_exact')
523 self.entree.bouton.mode_normal()
524 aide = resultat.startswith("\n== Aide sur ")
525 if aide:
526 latex = ''
527 elif not latex:
528 latex = resultat
529 #LaTeX
530 debug("Expression LaTeX: " + latex)
531 try:
532 try:
533 # Affichage en LaTeX si possible.
534 self.modifier_pp_texte(latex)
535 except Exception:
536 print_error()
537 # Sinon, affichage en texte simple.
538 # `matplotlib.mathtext` est encore loin d'être
539 # pleinement compatible avec LaTeX !
540 self.modifier_pp_texte(resultat)
541 except Exception:
542 print_error()
543 # Si tout a raté... mais ça ne devrait jamais arrivé.
544 self.modifier_pp_texte("<Affichage impossible>")
545 #Presse-papier
546 self.dernier_resultat = resultat
547 if self.param("copie_automatique"):
548 if self.param("copie_automatique_LaTeX"):
549 self.copier_latex()
550 else:
551 self.vers_presse_papier()
552 # TextCtrl
553 numero = str(len(self.interprete.derniers_resultats))
554 # Évite le décalage entre la première ligne et les suivantes (matrices)
555 if "\n" in resultat and not aide:
556 resultat = "\n" + "\n".join(20*" " + ligne for ligne in resultat.split("\n"))
557 self.resultats.moveCursor(QTextCursor.End)
558 self.resultats.insertPlainText(" Calcul n\xb0" + numero + " : "
559 + commande + "\n Résultat :"
560 + " "*(4+len(numero))
561 + resultat + "\n__________________\n\n")
562 self.resultats.moveCursor(QTextCursor.End)
563 self.message("Calcul effectué." + self.interprete.warning)
564 self.entree.clear()
565 # self.resultats.setCursorPosition(len(self.resultats.plainText()))
566 # self.resultats.setFocus()
567 # self.resultats.ScrollLines(1)
568 self.entree.setFocus()
569 except Exception:
570 self.message("Calcul impossible.")
571 self.entree.setFocus()
572 if param.debug:
573 raise
574
575
576 def insere(self, event=None, nom='', parentheses=True):
577 entree = self.entree
578 deb, fin = entree.getSelection()
579 if parentheses:
580 entree.setCursorPosition(fin)
581 entree.insert(")")
582 entree.setCursorPosition(deb)
583 entree.insert(nom + "(")
584 entree.setFocus()
585 if deb == fin:
586 final = fin + len(nom) + 1
587 else:
588 final = fin + len(nom) + 2
589 else:
590 entree.insert(nom)
591 final = fin + len(nom)
592 entree.setFocus()
593 entree.setCursorPosition(final)
594
595
596 def EvtMenu(self, event):
597 menu = QMenu()
598 menu.setWindowTitle("Fonctions mathématiques")
599 debut = True
600 for rubrique in __classement__:
601 if not debut:
602 menu.addSeparator()
603 debut = False
604 for titre, nom, doc in (_f for _f in __classement__[rubrique] if _f):
605 action = menu.addAction(titre, partial(self.insere, nom=nom, parentheses=(rubrique != "Symboles")))
606 # Pas de parenthèses après un symbole.
607 action.setToolTip(doc)
608 menu.exec_(QCursor.pos())
609
610
611 def EvtMenuVisualisation(self, event):
612 menu = QMenu()
613 action = menu.addAction("Copier LaTeX", self.copier_latex)
614 action.setToolTip("Copier le code LaTeX dans le presse-papier.")
615 menu.exec_(QCursor.pos())
616
617 def EvtCurrentChanged(self, index):
618 self.param('onglet', index)
619
620 def param(self, parametre, valeur = no_argument, defaut = False):
621 if valeur is not no_argument:
622 setattr(self.interprete, parametre, valeur)
623 return Panel_simple.param(self, parametre = parametre, valeur = valeur, defaut = defaut)
624
625 def EtatInterne(self, event):
626 contenu = self.interprete.save_state()
627 h = FenCode(self, "État interne de l'interprète", contenu, self.interprete.load_state)
628 h.show()