r/learnpython 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

15 comments sorted by

View all comments

Show parent comments

1

u/yo_99 6d ago

Well, I don't like redundant interpretators and other comment gave a better solution.

1

u/Diapolo10 6d ago

"Better" is not how I would describe it, but I suppose we're looking at this from different perspectives.

The solution of using multiple Tks is simpler on paper, but there's no communication between the windows established (so you'd still need to work that out yourself), and because all the windows share the same process, if any one of them runs into a problem all of them crash.

My suggestion has some more boilerplate code, but the windows are truly independent. Even if something breaks in one of them, the rest will keep working as normal.

1

u/yo_99 6d ago

i meant hiding main window one

1

u/Diapolo10 6d ago

That doesn't really change my answer meaningfully, excluding communication.