I'm trying to draw a graph in a tkinter window by reading some lists. These list are updating every time and I want the graphs change with the lists values.
I'm drawing the graphs with 'Canvas_create.line()' and giving coordinates in the tkinter window for each value.
I read these values inside I 'while True' loop, but when I put the 'root.mainloop()' sentence the process stops.
def drawAnalogicValues(variable,windowDraw,supValue,infValue):
global Change, StepX
Change = True
while True:
if Change == True: # If 'Change' = True, start drawing the variable
indexVariable = int(variable[1:])
valuesVariable = MatrixA_Values[indexVariable] # Se actual variable values
Change = False # Change the global variable 'Change' to False.
# Top and down coordx of window
coordYSup = 48
coordYInf = 452
rangePrint = coordYInf - coordYSup
# CorrdX to start the graph
coordXStart = 193
StepX = 0
for i in range(len(valuesVariable)-1):
actual = int(valuesVariable[i])
if valuesVariable[i+1] != None:
next = int(valuesVariable[i+1])
else:
# If none in list valuesVariable, the draw stops
break
# CoordX where is the graph for each step
coordX = coordXStart + StepX
# CoordY 'actual' and 'next' value
relativeActual = (valueSup-actual)/(valorSup - valorInf) # Percentage of the value, respect 'valueSup'
relativeNext = (valueSup-actual)/(valueSup - valueInf)
coordYActual = coordYSup + rangePrint*relativeActual
coordYNext = coordYSup + rangePrint*relativeNext
# Line for 'actual' to 'next' point
windowDraw.create_line(coordX,coordYActual,coordX+2,coordYNext,fill = 'red')
StepX = StepX + 2
windowDraw.mainloop()
I have no idea how can I do it. Thank you guys.