Python Forum
[Tkinter] Modal window
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Modal window
#11
OK, I'll explain the functionality, what would be the best approach then?

User opens a search program, and gets a single-select list(box) with
names of counties, provinces, French "préfectures"., etc.
He clicks on one of them, and the TopLevel opens, showing a list(box)
with all the villages in that county... , for which documents are available (prayer cards, marriage records, etc.)
This is just for info, the user can verify if the location he is interested in, has stuff available.
He can scroll the list f is is long.
The only thing he can do now, is click on the toplevel window close button.
No, he is not supposed to click on a village in the toplevel window,
because data are organised by event type first. (If you want marriage info, you don't look in prayer cards)
(Parish registers are also per type of event, at a lower geo level than village or town)
That's all, no dialog.
Paul

edit: I suppose that I do not need a "mainloop" for this window. Otherwise it throws an error when the window is closed.(tkinter.TclError)
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply
#12
I wouldn't make the viewing window modal, sllowing multiple viewing windows open at the same time.
Reply
#13
(Oct-17-2023, 09:40 AM)deanhystad Wrote: I wouldn't make the viewing window modal, sllowing multiple viewing windows open at the same time.
If your reason is programmatical, i need to think about it.
If it is functional, it is not necessary, there are not multiple things to view simultaneously.
...Or I don't understand what you are saying.
Paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply
#14
Users have their own needs that may seem odd to you.. Try to not get in their way. If there is a programmatic reason for making the window modal, make it modal. Don't make it modal just because you think there is no reason why anyone would view two counties at the same time.

This happens to me all the time, both as a user and a developer. The more flexible I make things the less time I spend changing the software to allow for unforseen use cases.
Reply
#15
(Oct-17-2023, 01:19 PM)deanhystad Wrote: The more flexible I make things the less time I spend changing the software
Point taken !
Paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply
#16
(Oct-15-2023, 06:51 AM)DPaul Wrote: Hi,
I'm getting pretty confused, reading about modal windows in tKinter.
I thought it would be simple.

I have an existing app,where users make a selection in a listbox, and go on from there.
However, as an extra service, I would like this selection to trigger a pop-up TopLevel window,
with a rather large amout of text.
That is easy.
BUT, I would like this TopLevel to be modal, so the user has to close it before moving on.

I had hoped that adding some parameter to "topWindow = Toplevel(height=500, width=200)"
would do the trick, but how ?
thanks,
Paul
Reply
#17
Use Grab_set:
def StartModalDialog(root_window):
    dialog=tk.Toplevel(root_window)
    dialog.grab_set()
buran write Nov-05-2024, 08:51 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Interaction between Matplotlib window, Python prompt and TKinter window NorbertMoussy 3 2,452 Mar-17-2024, 09:37 AM
Last Post: deanhystad
  tkinter window and turtle window error 1885 3 8,177 Nov-02-2019, 12:18 PM
Last Post: 1885
  Closing Modal Window in QT nieselfriem 0 5,422 Apr-19-2017, 03:32 PM
Last Post: nieselfriem
  update a variable in parent window after closing its toplevel window gray 5 11,005 Mar-20-2017, 10:35 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020