So i wanted to make a code that would get a value and turn it into a graph plot, the below code is working and showing the content of the .dat file, but it's not what my teacher wanted lmao
from tkinter import Tk, Label
def read_archive():
try:
archive = open("name_of_the_archive.dat", "r")
value = archive.read()
archive.close()
return value
except FileNotFoundError:
return "File not found"
window = Tk()
window.title("Value")
label_value = Label(window, text=read_archive(), font=("Arial", 18))
label_value.pack(pady=20)
window.mainloop()
Could somebody give me some info on how to do the graph, like a -pi to pi range or domething like that...thanks and sorry for my rookie programming and poor english :)
Suppose that your .dat file looks like this:
This is a list saves all the coordinates of the points on the gragh. I recommend using matplotlib instead of tkinter because users can easily plot graghs on matplotlib. (Perhaps your teacher asks you to do all of these only with tkinter.)
The full code: