A web site is sandboxed and cannot execute any external scripts – it is confined to the browser. But it can issue HTTP requests to a server. A server is not necessarily “a machine in some data center”, but more generally “any process that listens on some port and speaks HTTP”.
But how can that work without an internet connection? It is possible to run the server on the same computer as the browser. The server then listens on localhost, and no real network requests are made. For example, when I develop a site with static HTML files I often start a simple server with
python3 -m http.server -b localhost 8080. I can connect to the server by navigating to
http://localhost:8080/ in my browser.
Instead of a static file server, you would run your Python server on some port. Your users would then install your Python software and launch the server, then open the correct address in the browser to load the GUI.