How to skip matplotlib in python?

When I use matplotlib and I don’t close the chart window often (by clicking the mouse - close the window), I get the following error:

Exception RuntimeError: RuntimeError('main thread is not in main loop',) in <bound method PhotoImage.__del__ of <Tkinter.PhotoImage instance at 0x7ff408080998>> ignored Exception RuntimeError: RuntimeError('main thread is not in main loop',) in <bound method PhotoImage.__del__ of <Tkinter.PhotoImage instance at 0x7ff3fbe373f8>> ignored
                                                                   Tcl_AsyncDelete: async handler deleted by the wrong thread
                                                                                                                             Aborted

What I am doing: I have a method to call the main loop of an instance. The method matplotlibis threaded using the init function of this instance. I cannot call matplotlibas a method inside the instance, I do not know why, so I enter it through __init__:

def __init__(self):
....
thread = threading.Thread(target=self.drawcharts, args=())
        thread.daemon = False                            
        thread.start()

threaded method:

def drawcharts(self):

        global endthread

        ..do some 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 is endthreadtriggered by the exit function of my program (keyboard exception).

matplotlib , curses, , matplotlib . , .

, matplotlib - - - matplotlib. , .

? !

+4
1

matplotlib.show()

0

All Articles