Whenever I try to insert an item into a tkinter listbox from another thread it gives me this error: RuntimeError: main thread is not in main loop
The main parts of my code is down here:
Receive Thread:
# receive is running on another thread
def receive(event=None):
global msg
global recvinfo
while True:
try:
msg = client_socket.recv(BUFSIZ).decode("utf8")
decoded = cryptocode.decrypt(msg, PASS)
if decoded == "User Found":
recvinfo = 1
elif decoded == "User Not Found":
recvinfo = 2
elif decoded.startswith("gb:"):
smsg_list.insert(tkinter.END, decoded)
except OSError: # Client Side Exited Out
break
GUI Definition, running in main loop:
def maingui():
global smsg_list
receive_thread = Thread(target=receive)
receive_thread.start()
smsg_list = tkinter.Listbox(smessages_frame, height="21", width="75",)
smsg_list.pack(side=tkinter.LEFT, fill=tkinter.BOTH)
smsg_list.pack()