Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import sys
- from PyQt5.QtCore import Qt
- from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QSlider
- from PyQt5.QtChart import QChart, QChartView, QLineSeries
- from numpy import arange
- class Window(QWidget):
- def __init__(self):
- super().__init__()
- self.setGeometry(200, 200, 600, 400)
- self.setWindowTitle("График пиццы")
- self.k = 1
- self.series = QLineSeries()
- for x in arange(-10, 10, 0.003):
- y = math.sin(self.k * x)
- self.series.append(x, y)
- chart = QChart()
- chart.addSeries(self.series)
- chart.setAnimationOptions(QChart.SeriesAnimations)
- chart.setTitle("Синусоида")
- chart.setTheme(QChart.ChartThemeBlueCerulean)
- chart.createDefaultAxes()
- chartview = QChartView(chart)
- vbox = QVBoxLayout()
- sld = QSlider(Qt.Horizontal, self)
- sld.valueChanged[int].connect(self.changeValue)
- vbox.addWidget(chartview)
- vbox.addWidget(sld)
- self.setLayout(vbox)
- def changeValue(self, k):
- self.k = k / 10
- self.series.clear()
- for x in arange(-10, 10, 0.003):
- y = math.sin(self.k * x)
- self.series.append(x, y)
- App = QApplication(sys.argv)
- window = Window()
- window.show()
- sys.exit(App.exec())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement