Debian Codegraph @

wxgeometrie/GUI/console_geolib.py

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2
3 ##--------------------------------------##
4 # Console pour geolib #
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 PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel
25
26 from .app import white_palette
27 from .ligne_commande import LigneCommande
28 from ..pylib import print_error
29
30
31 class ConsoleGeolib(QWidget):
32 def __init__(self, parent):
33 QWidget.__init__(self, parent)
34 self.parent = parent
35 self.setPalette(white_palette)
36 vsizer = QVBoxLayout()
37 txt = "<i>Tapez une commande ci-dessus, puis appuyez sur </i>[<i>Entree</i>]<i>.</i>"
38 self.resultats = QLabel(txt)
39 self.resultats.setMinimumWidth(500)
40 self.ligne_commande = LigneCommande(self, longueur=500, action=self.action)
41 vsizer.addWidget(self.ligne_commande)
42 vsizer.addWidget(self.resultats)
43 self.setLayout(vsizer)
44
45 def action(self, commande, **kw):
46 try:
47 resultat = self.parent.feuille_actuelle.executer(commande)
48 self.resultats.setText(resultat)
49 print(resultat)
50 self.ligne_commande.clear()
51 except:
52 print_error()
53 self.resultats.setText('Erreur.')