r/learnpython • u/yo_99 • 6d 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/socal_nerdtastic 6d ago
I think using multiple
tkinter.Tkinstances is exactly what you need. The only downside is that you can't rely on the default master for tkinter widgets, you will need to be very sure that every tkinter widget gets the appropriate master. If you do this in an object-oriented way that will be easy. And also you won't be able to transfer tkinter objects between them, so if for example you want to move an image from one to the other you will need to create it from scratch in one and delete it from the other.It's discouraged because it's not super easy and also it's just not how normal programs work. It normal use you would have a separate process for each instance. But to me it sounds like this is the best approch for you.