I'm working on a program and I ran into a problem I'm not sure how to fix.
I'm gonna try to give a simplified example below.
The purpose of the code is to read data from a device and display the stream live. However in the GUI You can select what stream of data You wish to display.
import tkinter
import datastream.py
dataselector = 3
def ReDraw(dataselector):
if dataselector == 0:
#draw a certain stream
if dataselector == 1:
#draw another stream
#draw a bunch of other streams in other displays
canvas.after(10,ReDraw,dataselector)
def SelectData(mouseevent):
if event.clickedbutton == 0:
#thatbuttonbecomesred
dataselector = 0
if event.clickedbutton == 1:
#thatotherbuttonbecomesred
dataselector = 1
return dataselector
ReDraw(dataselector)
SelectData()
Sorry for the pseudo-code, but it's the simplest way to explain the problem.
The behavior I get is that everything draws and redraw correctly, the buttons do interact and become red BUT the ReDraw function only takes the original dataselector value and doesn't take the new one given by the SelectData function even if, testing with some prints, it indeed changes it.
It's like the ReDraw function takes the original value and store it secretly, ignoring any changes to that value!
I also tried using a global dataselector in the SelectData function instead, but it doesn't change anything.
Any suggestions how to fix this?