I use the up to date pycharm, python and packages to make a tkinter plot. However I keep getting the Error :
Process finished with exit code -1073741819 (0xC0000005)
I found that the "graph.draw()" line causes the Problem. However I searched now a lot and tried update everything and haven't found any solution.
The Code I use is from here
from tkinter import * from random import randint # these two imports are important from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg from matplotlib.figure import Figure import time import threading continuePlotting = False def change_state(): global continuePlotting if continuePlotting == True: continuePlotting = False else: continuePlotting = True def data_points(): f = open("data.txt", "w") for i in range(10): f.write(str(randint(0, 10)) + '\n') f.close() f = open("data.txt", "r") data = f.readlines() f.close() l =  for i in range(len(data)): l.append(int(data[i].rstrip("\n"))) return l def app(): # initialise a window. root = Tk() root.config(background='white') root.geometry("1000x700") lab = Label(root, text="Live Plotting", bg='white').pack() fig = Figure() ax = fig.add_subplot(111) ax.set_xlabel("X axis") ax.set_ylabel("Y axis") ax.grid() graph = FigureCanvasTkAgg(fig, master=root) graph.get_tk_widget().pack(side="top", fill='both', expand=True) def plotter(): while continuePlotting: ax.cla() ax.grid() dpts = data_points() ax.plot(range(10), dpts, marker='o', color='orange') graph.draw() time.sleep(1) def gui_handler(): change_state() threading.Thread(target=plotter).start() b = Button(root, text="Start/Stop", command=gui_handler, bg="red",fg="white") b.pack() root.mainloop() if __name__ == '__main__': app()
I also use another code where I got the same Problem. This example I just tried to verify it is not a Problem of my Coding.
How can I resolve the Problem?
User contributions licensed under CC BY-SA 3.0