Hi.I have this code:
What troubles is that the window isnt created when trying to run this,how do I solve this?
Python:
import socket
import threading
from tkinter import *
from tkinter import messagebox
port = 2222
filename = 'records.txt'
file = open(filename, 'a')
clients = []
window = Tk()
window.maxsize(100, 100)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind((socket.gethostname(), port))
sock.listen()
def listen():
while True:
client, address = sock.accept()
response = messagebox.askyesno('You have a new request', address)
if response == 'No':
client.close()
record = str(address) + ':' + 'access rejected'
file.write(record)
else:
clients.append(client)
record = str(address) + ':' + 'access granted'
file.write(record)
listen()
window.mainloop()