Python Forum
[Tkinter] calling a new window from a tkinter window
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] calling a new window from a tkinter window
#1
I'm having trouble navigating nested windows calls with tkinter. The first window builds and executes well, with a window.mainloop() statement at at the end to set up the window polling.

But now, when I use a button to call a function, which in turn, opens up a new window, I end up with a parallel window that does not wait for the return values returned by the second function. In this case the second window is just a simple dropdown menu, with user selected choice, which should be returned to the main function. Everything works, except the code that calls the new window doesn't wait, and then execute subsequent code. I started exploring wait_window(), but don't understand how that might help.
Reply
#2
I don't understand what you are asking, can you show a minimal example of runnable code.
Reply
#3
In a script you can write some text, prompt for input, and perform some action based on the input. In a GUI you cannot use this pattern because the GUI cannot control what the user does next. If you draw a window with a menu the user might close your window and not make a menu selection. This must be allowed. In a GUI application you would draw the window with the menu, and specify a function to call when the menu selection is made.

So if your logic is:
Make menu
Draw menu
Wait for selection
Process selection

You should change it to:
Make menu, bind menu to call Process selection
Draw Menu
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  GUI created in Tkinter does NOT show up RCasanuevaU 3 445 Apr-09-2025, 04:47 PM
Last Post: RCasanuevaU
  [Tkinter] Sudoku solver with tkinter flash77 9 8,958 Apr-03-2025, 01:01 PM
Last Post: gibbon
  tkinter Radio button group not setting default selection simonc88 3 865 Mar-20-2025, 06:53 PM
Last Post: buran
  Transparent window background, but not text on it muzicman0 8 6,830 Feb-13-2025, 06:16 AM
Last Post: elonnmusk
  Multiply function using Tkinter ady1583 7 11,221 Feb-09-2025, 02:58 PM
Last Post: frankjoesmith
  [Tkinter] Tkinter & Application flow issues - using multi-threaded for GUI caarsonr 4 1,833 Jan-06-2025, 01:35 AM
Last Post: deanhystad
  [PyQt] Popup window not coming RamanSMann 2 801 Jan-02-2025, 02:18 AM
Last Post: lyly19
  Using place for a button, many examples but AttributeError, tkinter Edward_ 3 953 Dec-17-2024, 09:06 PM
Last Post: deanhystad
  [Kivy] Asynchronous operation without window freezing T800 0 676 Dec-06-2024, 05:40 AM
Last Post: T800
Smile Unable to display Devanagari ligatures correctly in python tkinter Anamika 4 1,359 Nov-26-2024, 08:08 PM
Last Post: woooee

Forum Jump:

User Panel Messages

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