Debian Codegraph @

wxgeometrie/GUI/inspecteur.py

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2
3 ##--------------------------------------#######
4 # Fenetres #
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
25 from PyQt5.QtWidgets import QDialog, QPushButton, QVBoxLayout, QHBoxLayout
26 from PyQt5.QtCore import Qt
27
28 from .pythonSTC import PythonSTC
29
30 class EditeurPython(PythonSTC):
31 def __init__(self, parent):
32 super(EditeurPython, self).__init__(parent)
33 self.parent = parent
34
35 def keyPressEvent(self, event):
36 print("test!!!")
37 key = event.key()
38 if key == Qt.Key_Escape:
39 self.parent.close()
40 elif key == Qt.Key_F5:
41 self.parent.executer()
42 else:
43 super(EditeurPython, self).keyPressEvent(event)
44
45
46 class FenCode(QDialog):
47 """Permet d'éditer du code Python.
48
49 En particulier, permet d'éditer le code de la feuille actuelle."""
50 def __init__(self, parent, titre, contenu, fonction_modif):
51 QDialog.__init__(self, parent)
52 self.setWindowTitle(titre)
53 sizer = QVBoxLayout()
54 self.parent = parent
55 self.fonction_modif = fonction_modif
56 self.texte = EditeurPython(self)
57 # self.texte.setMinimumSize(300, 10)
58 self.texte.setText(contenu)
59 ## self.texte.SetInsertionPointEnd()
60 sizer.addWidget(self.texte)
61
62 boutons = QHBoxLayout()
63 self.btn_modif = QPushButton("Modifier - F5")
64 boutons.addWidget(self.btn_modif)
65 self.btn_esc = QPushButton("Annuler - ESC")
66 boutons.addStretch()
67 boutons.addWidget(self.btn_esc)
68 sizer.addLayout(boutons)
69 self.setLayout(sizer)
70
71 self.btn_modif.clicked.connect(self.executer)
72 self.btn_esc.clicked.connect(self.close)
73
74 self.setMinimumSize(400, 500)
75 self.texte.setFocus()
76
77
78
79
80 def executer(self, event = None):
81 # On exécute le code (de la feuille par ex.) éventuellement modifié
82 self.fonction_modif(self.texte.text())
83 self.close()