Hello everyone!
I am writing my problem, my big thank you for your time and help.
So, here is it:
I am creating a GraphicsPlot object, then I add a plot, then I plot pen
style with plot(pen='y'). And I have a function which setData in the window
created. But this windows closes very fast.
My quest is: How can I keep the plotting window active ?
Here is the code:
'''from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
app = QtGui.QApplication([])
win = pg.GraphicsWindow(title="Basic plotting examples")
win.resize(1000,600)
win.setWindowTitle('pyqtgraph example: Plotting')
graf = win.addPlot(title="Updating")
curve = graf.plot(pen='r')
import random
x = random.sample(range(1,100),7)
curve.setData(x)
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()'''
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton
import sys
import pyqtgraph as pg
class GraphPlot(object):
def __init__(self, title = "Default window title", size_x= 640, size_y
= 480):
self.win = pg.GraphicsWindow()
self.win.resize(size_x, size_y)
self.win.setWindowTitle(title)
self.graf = self.win.addPlot()
self.curve = self.graf.plot(pen='y')
self.win.show()
def plot(self, data_x):
self.curve.setData(data_x)
class AnalyzerApp(QMainWindow):
def __init__(self):
super().__init__()
self.left = 10
self.top = 10
self.title = "Title"
self.width = 1170
self.height = 720
self.initUI()
def initUI(self):
self.setGeometry(self.left,self.top,self.width,self.height)
self.setWindowTitle(self.title)
self.btn = QPushButton("Button", self)
self.btn.move(500, 500)
self.btn.clicked.connect(self.fxn1)
self.show()
def fxn1(self):
import random
graf = GraphPlot()
data = random.sample(range(1,100),3)
print(data)
graf.plot(data)
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = AnalyzerApp()
sys.exit(app.exec_())
Thank you very much!
--
You received this message because you are subscribed to the Google Groups
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyqtgraph/1d2f5cd2-361d-455e-b77e-bc91211be775%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.