Good morning all,
I have a problem with my code. I get a list from a file.txt. I would like that with the Tkinter create line tool, create a drawing automatically.
Note that my list can contain 4 items, like 30 items.
So I would like to browse my entire list until the end.
Here is the code:
from tkinter import *
# Fenêtre
root = Tk()
Largeur = 1200
Hauteur = 800
canvas = Canvas(root, width=Largeur, height=Hauteur, background="white")
canvas.pack(side=LEFT, padx=5, pady=5)
root.resizable(width=False, height=False)
root.title('Heating Draw')
with open("valeur_x_y.txt", "r+") as file:
liste_complet = file.readlines()
file.close()
canvas.create_line(liste_complet[0], liste_complet[1], liste_complet[2], liste_complet[3], fill="red", width=3)
canvas.create_line(liste_complet[2], liste_complet[3], liste_complet[4], liste_complet[5], fill="red", width=3)
canvas.create_line(liste_complet[4], liste_complet[5], liste_complet[6], liste_complet[7], fill="red", width=3)
root.mainloop()
Can you help me?
Thank you