Skip to content Skip to sidebar Skip to footer

Reading Higher Frequency Data In Thread And Plotting Graph In Real-time With Tkinter

In the last couple of weeks, I've been trying to make an application that can read EEG data from OpenBCI Cyton (@250Hz) and plot a graph in 'real-time'. What seems to work better h

Solution 1:

after() (similar to button's command= and bind()) needs function's name without () and without argument - it is called callback - and after sends it to mainloop and mainloop later uses () to run it.

You use function with ()

 app.root.after(60, plotSamples(flag,app,kounter))

so it runs it at once (it doesn't send it to mainloop) and this function runs at once again the same function which runs at once the same function, etc. - so you create recursion.

It works like

result= plotSamples(flag,app,kounter) # run at once
 app.root.after(60, result)

If you have to use function with arguments then you can do

 app.root.after(60, plotSamples, flag, app, kounter)

Eventually you can use lambda to create function without argument

 app.root.after(60, lambda:plotSamples(flag,app,kounter) )

Post a Comment for "Reading Higher Frequency Data In Thread And Plotting Graph In Real-time With Tkinter"