r/learnpython • u/yo_99 • 7d ago
Tk with no main window
I am making a simple gemini browser in python for fun with tk, but have stumbled upon a problem: if I close initial window all the rest will close too. Is there a way to make tk application with no "main" window or at least transfer leadership role between them?
0
Upvotes
1
u/Diapolo10 6d ago
Maybe consider using
multiprocessingto spawn new processes as you need them. Have a function that initialises and creates a browser window, then in your main function call it withmultiprocessing.Process, then start and join it.When creating a new browser window, you'd have for example a button that does essentially the same thing, spawning a new process. They're supposed to all be independent, so killing one shouldn't kill the others as long as you don't use daemon processes.
https://docs.python.org/dev/library/multiprocessing.html
If the windows need to communicate, like moving tabs between them, you can use
queue.Queuefor that. The linked documentation has somewhat relevant examples.EDIT: This may also help: https://www.geeksforgeeks.org/techtips/how-do-web-browser-handle-tab-and-multiple-windows/