Wrote a tiny program which should start animating a graph if some specific message is send to an zmq socket. For zmq socket listening i use threads. If the specific message is received from within the thread it sends a virtual event to the root window. However the event is also triggered when binding to the root... how can this be? and how to solve it ...
Setting up a listener thread which sends a virtual event when received a command :
def commandReceiver():
global commandAfterStart
while True:
commands = zmq_.recv_string()
if 'START' in commands.upper():
commandAfterStart = commands.replace("START ","")
root.event_generate("<<Foo>>", when="tail")
print ("Command received = "+commandAfterStart)
commandThread = threading.Thread(target=commandReceiver, args=(), daemon=True)
commandThread.start()
In the main thread
def doShow(*args):
anim = FuncAnimation(fig, showGraph, 300)
print("Animation started")
return anim
root.bind("<<Foo>>", doShow())
However the event fires even on program startup... Anyone a clue how to fix this ?