Question
How to run the Tkinter mainloop
and an infinite server loop simultaneously, in the same script?
Background
I am in the process of creating a GUI server in Tkinter (Python 2.7.3). So far, the GUI works correctly, the Server works correctly, but I am having issues integrating the two. As far as I know (correct me if I am wrong) the server needs to be running on an infinite loop to accept new users. Sadly, the GUI also needs an infinite loop. I am wondering how to have both loops running at the same time.
My current mainloop function looks like this (s
is the socket object):
def mainloop(s):
while True:
channel, addr = s.accept()
print "Connected with", addr
That is obviously needed to keep the server running (I think.) The issue though, is that this loop comes before my mainloop
and thus I have problems with that. If I do it the other way around, the Server is never opened.
Full Code
My server code is here, and my client is here.
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…