So I have written a program which has the purpose of recieving values from Tkinter GUI and then sending them to another computer from socket.
Problem is that Tkinter hogs all the loop. I've tried using root.after() but the socket stuff relies on the .get() function, so when called upon since the GUI hasn't appeared yet, there isn't any values for what I'm trying to send.
Here's a more simple code example of what I'm trying to do (mine is much larger, well about 10 different variables larger)
HOST= 'ip address'
PORT = 8000
s= socket(AF_INET, SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1) #I'm aiming for this to eventually be 24.
conn, addr = s.accept
def data():
Value = str(value.get())
conn.sendall(str(Value))
root = Tk()
value = Scale(root, from_=255, to=0)
value.set(60)
value.pack() #not using pack but grid. Pack is just easier for simple example.
root.after(500, data())
root.mainloop()
So how do I have this all running in the loop? So it sends the data as the changes are made? (hopefully every second, is what I'm aiming for). I understand the issue with having root.after before root.mainloop, but it won't work otherwise. Mind you, it doesn't work the other way anyway.
I'm thinking thread and queue might be the only solution but I have always struggled with those modules.
I need it to constantly loop both program components to constantly send the data as the GUI slides change.