Jan-23-2018, 07:46 AM
I have some Tkinter top-level windows that were created by matplotlib (backend: TkAgg), in Python 3 on debian.
Naturally the user can change their stacking order by clicking on their title bars to raise them.
The windows have type tkinter.Tk.
I can raise a window w programmatically by a statement like w.tkraise().
But what i need to do is determine which window the user has raised to the top (so that the program i'm writing can then do something to it).
That is, i need to determine which window is on top, rather than just sending one to the front.
The frontend matplotlib.pyplot module has a function gcf() which is documented to return the current figure (gcf == 'get current figure'). And from this figure, i can determine the its window (matplotlib.pyplot.gcf().canvas.manager.window). However, the return value of gcf() does not track which window is on top, so it seems to be using something else to decide what's current.
I would appreciate very much any clues about how to programmatically determine what window is actually on top. (Any advice is fine, no matter whether hackey, or a pointer to the manual, or anything else. This would seem to be a natural question, but i can't seem to find it on google.)
dan
Naturally the user can change their stacking order by clicking on their title bars to raise them.
The windows have type tkinter.Tk.
I can raise a window w programmatically by a statement like w.tkraise().
But what i need to do is determine which window the user has raised to the top (so that the program i'm writing can then do something to it).
That is, i need to determine which window is on top, rather than just sending one to the front.
The frontend matplotlib.pyplot module has a function gcf() which is documented to return the current figure (gcf == 'get current figure'). And from this figure, i can determine the its window (matplotlib.pyplot.gcf().canvas.manager.window). However, the return value of gcf() does not track which window is on top, so it seems to be using something else to decide what's current.
I would appreciate very much any clues about how to programmatically determine what window is actually on top. (Any advice is fine, no matter whether hackey, or a pointer to the manual, or anything else. This would seem to be a natural question, but i can't seem to find it on google.)
dan