Make toplevel not trigger FocusOut of parent widget (tkinter)

38 Views Asked by At

I am trying to make switching focus over to toplevel not trigger frame's event.

I tried setting toplevel's master to frame, but this didnt work.

Any ideas of how to do this?

TIA

Below is my code:

from tkinter import Tk, Frame, Entry, Toplevel


def focus_out(event):
    print("focus out")


root = Tk()
root.title("Main")
root.geometry("400x400")

frame = Frame(root)
frame.pack()
frame.bind("<FocusOut>", focus_out)

e = Entry(frame)
e.pack()


t = Toplevel(frame)
t.geometry("400x400")
t.title("top level")
Entry(t).pack()


root.mainloop()

If the user clicks into the entry, and then into the entry of toplevel, the focusout event triggers. I want it to not trigger. Is this possible?

0

There are 0 best solutions below