Determine which Tkinter widget is on top (or visible)

I would like to determine which widget (frame in this case) is on top (or visible in any case).

from Tkinter import *
spam1=0
spam2=1000

def busywork():
    global spam1
    global spam2
    #if frame1 is on top / visible
    spam1=spam1+1
    label1.config(text=str(spam1))

    #if frame2 is on top / visable
    spam2=spam2+1
    label2.config(text=str(spam2))
    root.after(10,busywork)

root=Tk()
frame1=Frame(root)
frame2=Frame(root)

button1=Button(frame1,text="Bring Frame 2 to top",command=frame2.lift)
label1=Label(frame1,text=str(spam1))
button1.pack()
label1.pack()
frame1.place(relx=0,rely=0)


button2=Button(frame2,text="Bring Frame 1 to top",command=frame1.lift)
label2=Label(frame2,text=str(spam2))
button2.pack()
label2.pack()
frame2.place(relx=0,rely=0)
root.after(10,busywork)
root.mainloop()

[This is close], but it works for windows without frames (or widgets in general)

. . busywork . . , . , , .lift() ed. . ( 400 , 60, "" , )

+4
1

, , , .

:

frame1 = Frame(...)
frame1.visible = False

visible = frame1

update,

visible.update( all_data )
+2

Source: https://habr.com/ru/post/1548101/


All Articles