I was wondering if it is possible to get a list of windows in Tk, and destroy specific ones. I am working in R using the tcltk interface, and am calling a function written by someone else a long time ago (that I cannot edit) which is producing additional windows that I don't want.
From the documentation here, it seems that new Toplevel
windows are children of .TkRoot
by default. I know that Python has a winfo_children
method, which I was thinking of trying to call on .TkRoot
but I don't think that method is implemented in the tcltk library. I tried using tcl("winfo", "children", .TkRoot)
but I am getting an error: [tcl] bad window path name "{}"
(I'm not familiar with actual tcl, so I'm probably messing this command up).
Additionally, if there is a way to call winfo children
, what's the best way to process the result to identify specific windows and then destroy them?