How can i wait for a Tcl/Tk toplevel widget to be created before moving on?

StackOverflow https://stackoverflow.com/questions/22612451

  •  20-06-2023
  •  | 
  •  

سؤال

I'm using Tcl/Tk to build a UI and im running into the problem of trying to interact with a toplevel window before it's actually been created.

I created the toplevel window like this:

toplevel .t

Then i try and interact with it like this:

wm stackorder .t isabove .

But .t doesn't exist yet and i get an error about the window not being mapped. Effectively it equates to doing this:

winfo ismapped [toplevel .t]

which returns 0 but if i immediately run the following:

winfo ismapped .t

Then the return value is 1.

How can i know when a toplevel window is mapped (and therefore ready to interact with) so that i can proceed with my program?

هل كانت مفيدة؟

المحلول

I found the answer, i needed the following:

tkwait visibility .t
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top