Is there a way to popup new window upon new connection using python socketserver and python Gtk?
server.py has the following classes
class Handler(BaseRequestHandler):
def handle(self):
...
# self.win = ClientWindow(self)
# GLib.idle_add(self.popup)
def popup(self):
self.win = ClientWindow(self)
return False
class Server(ThreadingTCPServer, ThreadingMixIn):
allow_reuse_address = True
window.py
class ClientWindow(Gtk.Window):
def __init__(self, con):
super().__init__(title=f"{con.client_address[0]}:{con.client_address[1]}")
self.set_default_size(500, 500)
self.connect("destroy", self.close_window)
self.con = con
self.show_all()
def close_window(self):
self.hide()
The goal is to server the client connection from the window.
I tried using GLib.idle_add in Handler class to pop up the new window but the socket file descriptor is -1 meaning the connection is already closed.
Another approach was to create the client window in the handle method in Handler class but this also does not work.