Python2.7 PyQT4
Не получается создать график в отдельном модальном окне окне.
class MyModalWingraphik(QtGui.QWidget): def __init__(self,parent, flag, *args, **kwargs): QtGui.QWidget.__init__(self, parent, flag, *args, **kwargs) self.setWindowFlags(flag|QtCore.Qt.CustomizeWindowHint) self.setWindowModality(QtCore.Qt.WindowModal) #layout = QtGui.QGridLayout(self) #self.setLayout(layout) #------------------------------------------- view = pg.GraphicsLayoutWidget() layout.addWidget(view) #mw.setCentralWidget(view) #mw.setWindowTitle('pyqtgraph example: ScatterPlot') stringaxis = TimeAxisItem(orientation='bottom') w1 = view.addPlot(axisItems={'bottom': stringaxis}) x = ['0:09:48', '0:09:49', '0:09:50', '0:09:51', '0:09:52', '0:09:53', '0:09:54', '0:09:55', '0:09:56', '0:09:57'] y = [10, 8, 6, 4, 2, 20, 18, 16, 14, 12] time = QtCore.QTime.currentTime() QtCore.qsrand(time.msec()) for xi, yi in zip(x, y): s = pg.ScatterPlotItem([QtCore.QTime(0, 0, 0).secsTo(QtCore.QTime.fromString(xi, "h:mm:ss"))], [yi], size=10, pen=pg.mkPen(None)) s.setBrush(QtGui.QBrush(QtGui.QColor(QtCore.qrand() % 256, QtCore.qrand() % 256, QtCore.qrand() % 256))) w1.addItem(s) #------------------------------------------- ##---- self.button3 = QtGui.QPushButton(u"Выход", self) self.button3.clicked.connect(self.deleteLater) self.button3.setGeometry(10, 40, 80, 20) def closeEvent(self, QMesBox): #sys.exit(app.exec_()) pass #=================================================== class TimeAxisItem(pg.AxisItem): def tickStrings(self, values, scale, spacing): return [QtCore.QTime(0, 0, 0).addSecs(value).toString() for value in values]
Модальное окно вызывается:
def show_modal_wingrafik(self):
window2 = MyModalWingraphik(self, QtCore.Qt.Dialog)
window2.setWindowTitle(u"График")
window2.setGeometry(0, 0, 480, 272)
window2.show()
Задача: есть дата и время (ось x) , а ось y это некоторые данные, нужно построить график по массиву времени и данных.
Подскажите, что можно сделать
