multithreading - How to thread Matplotlib in Python? -
when thread matplotlib , dont close graph window (by mouse - close window button) following error:
exception runtimeerror: runtimeerror('main thread not in main loop',) in <bound method photoimage.__del__ of <tkinter.photoimage instance @ 0x7ff408080998>> ignored exception runtimeerror: runtimeerror('main thread not in main loop',) in <bound method photoimage.__del__ of <tkinter.photoimage instance @ 0x7ff3fbe373f8>> ignored tcl_asyncdelete: async handler deleted wrong thread aborted
what do: have main loop calling methods of instance. matplotlib
method threaded init function of instance. cant call matplotlib
method inside instance, don't know why, thread via __init__
:
def __init__(self): .... thread = threading.thread(target=self.drawcharts, args=()) thread.daemon = false thread.start()
the threaded method:
def drawcharts(self): global endthread ..do math.. try: plt.plot(k) plt.plot(x1) plt.plot(x2) plt.plot(x3) #plt.plot(v) plt.ylabel('some numbers') plt.show(block=true) self.drawcharts(); except: self.drawcharts() if endthread==1: return return
the global variable endthread
triggered exit function of program (keyboard exception).
i need matplotlib
run independently rest of program, curses program , cant change structure, matplotlib
can run in non-blocking mode or else. need blocking mode widgets of plot-window needed.
i suppose loop on same matplotlib window on , on - without closing plot windows - makes overflow in matplotlib. time works charm, exits ungracefully.
what can it? help!
you should questions , answers making matplotlib.show()
non-blocking
Comments
Post a Comment