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
| from PyQt5 import QtCore
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
import os,sys
import numpy as np
from pylab import *
class fenPrincipale(QMainWindow):
def __init__(self):
global theta, x, y, nb_points
QMainWindow.__init__(self)
fenetre_widget = QWidget()
self.pen=QPen()
self.nb_points=QSpinBox()
self.nb_points.setRange(3, 350)
self.scene=QGraphicsScene()
self.scene.setSceneRect(0,0,0,0)
LayoutV=QVBoxLayout()
LayoutV.addWidget(self.nb_points)
self.view =QGraphicsView(self.scene)
LayoutV.addWidget(self.view)
fenetre_widget.setLayout(LayoutV)
self.setCentralWidget(fenetre_widget)
nb_points=self.nb_points.value()
theta = np.linspace(0, 2*np.pi, nb_points+1)
x = np.cos(theta)
y = np.sin(theta)
self.nb_points.valueChanged.connect(self.dessin_graphique)
def dessin_graphique(self):
self.scene.clear()
nb_points=self.nb_points.value()
theta = np.linspace(0, 2*np.pi, nb_points+1)
x = np.cos(theta)
y = np.sin(theta)
for i in range(0, nb_points):
self.scene.addLine(x[i]*100,y[i]*100,x[i+1]*100,y[i+1]*100,self.pen)
#def representation_table(self):
# self.scene.clear()
# nb_points=self.nb_points.value()
# theta = np.linspace(0, 2*np.pi, nb_points+1)
# x = np.cos(theta)
# y = np.sin(theta)
# for i in range(0, nb_points):
# self.scene.addLine(x[i]*100,y[i]*100,x[i+1]*100,y[i+1]*100,self.pen)
def initialisation(self):
nb_points=self.nb_points.value()
theta = np.linspace(0, 2*np.pi, nb_points+1)
x = np.cos(theta)
y = np.sin(theta)
def main(args):
appli=QApplication(args)
fenetre=fenPrincipale()
fenetre.show()
r=appli.exec_()
return r
if __name__=="__main__":
main(sys.argv) |
Partager