1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
import sys
import numpy as np
from PyQt5 import QtGui, QtCore
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QAction, QDesktopWidget, QComboBox, QLabel, QPushButton, QMessageBox, QGridLayout
from qwt.qt.QtGui import QApplication, QPen
from qwt.qt.QtCore import Qt
from qwt import QwtPlot, QwtPlotMarker, QwtLegend, QwtPlotCurve, QwtText
class SimplePlot(QwtPlot):
def __init__(self, *args):
QwtPlot.__init__(self, *args)
self.setTitle('ReallySimpleDemo.py')
self.insertLegend(QwtLegend(), QwtPlot.RightLegend)
self.setAxisTitle(QwtPlot.xBottom, 'x -->')
self.setAxisTitle(QwtPlot.yLeft, 'y -->')
self.enableAxis(self.xBottom)
# insert a few curves
cSin = QwtPlotCurve('y = sin(x)')
cSin.setPen(QPen(Qt.red))
cSin.attach(self)
cCos = QwtPlotCurve('y = cos(x)')
cCos.setPen(QPen(Qt.blue))
cCos.attach(self)
# make a Numeric array for the horizontal data
x = np.arange(0.0, 10.0, 0.1)
# initialize the data
cSin.setData(x, np.sin(x))
cCos.setData(x, np.cos(x))
# insert a horizontal marker at y = 0
mY = QwtPlotMarker()
mY.setLabel(QwtText('y = 0'))
mY.setLabelAlignment(Qt.AlignRight | Qt.AlignTop)
mY.setLineStyle(QwtPlotMarker.HLine)
mY.setYValue(0.0)
mY.attach(self)
# insert a vertical marker at x = 2 pi
mX = QwtPlotMarker()
mX.setLabel(QwtText('x = 2 pi'))
mX.setLabelAlignment(Qt.AlignRight | Qt.AlignTop)
mX.setLineStyle(QwtPlotMarker.VLine)
mX.setXValue(2*np.pi)
mX.attach(self)
# replot
self.replot()
class MainWindow(QMainWindow):
def __init__(self):
self.labelProfiles = QLabel("Profiles", self)
self.labelProfiles.setText("List of printer profiles:")
self.labelProfiles.move(10, 35)
self.labelProfiles.resize(200, 20)
posit = QGridLayout()
posit.addWidget(self.demo, 1, 0)
self.setLayout(posit)
self.encours = False
#Lancer la Fenêtre
app = QApplication(sys.argv)
GUI = MainWindow()
GUI.show()
sys.exit(app.exec_()) |
Partager