I'm trying to make a client-server package into one app. So when the app is open the server automatically goes into standby/listen mode. The issue is when running the server socket it doesn't show the gui until after socket.accept()
. i would like the gui and the server socket to happen at the same time.
I have commented out lines of code and it works as intended up to the point of conn,addr=s.accept()
imports*
root= Tk()
#main config
#mouse drag
# ------------------ Server Socket ------------------
connectionStatus = Label(rootCanvasBG)
connectionStatus.grid(column=0, row=7)
s = socket.socket()
host = socket.gethostname()
port = 8080
s.bind((host, port))
s.listen(10)
print(host)
print('waiting for connection')
connectionStatus.config(text='Waiting for any incoming connections')
conn, addr = s.accept() # thread issue, not showing tkinter
connectionStatus.config(text=addr)
print(addr, 'connected')
#Layout
root.mainloop()
I have read about threading to resolve this but no examples I have seen gave clear enough answers. I am still fairly new to python and programming in general. Thanks