If you not plan to use classes maybe could start with:






































*import multiprocessingimport numpy as npimport sysimport pyqtgraph as
pgimport ReadDatadef main():    global curve1, matrix_main    # global
qapp        matrix_main = np.memmap('myData.dat', dtype='float64',
mode='w+', shape=(5000, 5))    p =
multiprocessing.Process(target=ReadData.worker)    p.start()
qapp=pg.mkQApp()    win1 = pg.GraphicsWindow()    win1.setWindowTitle('Data
plot')    win1.show()    p1 = win1.addPlot()    index = int(matrix_main[0,
0])    curve1 = p1.plot(matrix_main[:index, 2], pen='k')    #
qapp.processEvents()    timer = pg.QtCore.QTimer()
timer.timeout.connect(update1)    timer.start(1000)
sys.exit(qapp.exec_())def update1():    global curve1, matrix_main    #
global qapp    index = int(matrix_main[0, 0])
curve1.setData(matrix_main[:index, 2])    # qapp.processEvents()main()*


P.S. I am not sure that processEvents is necessary, so I commented it out.


Good luck,
Vasilije

On Fri, Aug 5, 2016 at 7:06 PM, <[email protected]> wrote:

> Hi All,
>
> I have recently started using Python and pyqtgraph so apologies for a
> rather basic question. I am trying to read some data from a file and plot
> it using pyqtgraph (as given in the code below). All the plot
> initialization is done in the main function and then the plot is updated
> through a QTimer. However, when I try to run this code, it returns the
> error:
>
> QtGui.QApplication.instance().exec_()
> AttributeError: 'NoneType' object has no attribute 'exec_'
>
> Any help with this would be much appreciated.
>
> Thanks.
>
> import multiprocessing
> import numpy as np
> import sys
> import pyqtgraph as pg
> from pyqtgraph.Qt import QtCore, QtGui
> import ReadData
>
> def main():
>     matrix_main = np.memmap('myData.dat', dtype='float64', mode='w+', 
> shape=(5000, 5))
>
>     p = multiprocessing.Process(target=ReadData.worker)
>     p.start()
>
>     win1 = pg.GraphicsWindow()
>     win1.setWindowTitle('Data plot')
>
>     p1 = win1.addPlot()
>
>     index = int(matrix_main[0, 0])
>     curve1 = p1.plot(matrix_main[:index, 2], pen='k')
>     pg.QtGui.QApplication.processEvents()
>     timer = pg.QtCore.QTimer()
>     timer.timeout.connect(update1)
>     timer.start(1000)
>
> def update1():
>     global curve1, matrix_main
>     index = int(matrix_main[0, 0])
>     curve1.setData(matrix_main[:index, 2])
>
> if __name__ == '__main__':
>     if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
>         QtGui.QApplication.instance().exec_()
>         main()
>
>
>
> --
> 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/59f2c28e-34a9-4c28-8ad6-2670422932c3%40googlegroups.com
> <https://groups.google.com/d/msgid/pyqtgraph/59f2c28e-34a9-4c28-8ad6-2670422932c3%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAD_qyJqfJf6_ZS0SFzVGWxXEu_0ogvCUSvH5DV3VqCU%3DABpi6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to