How to know if a given widget is focussed? #2849
Unanswered
BhagyaJyoti22006
asked this question in
Q&A
Replies: 1 comment
|
They are related, but not the same widget.
while the outer CustomTkinter widget is: So this comparison fails: focused_widget.winfo_name() == widget.winfo_name()because you are comparing the inner Tk entry with the outer CTk wrapper. For a def check_focus(widget):
widget.focus_set()
root.update()
focused_widget = root.focus_get()
if focused_widget == widget._entry:
print("The widget is focused.")
else:
print("The widget is not focused.")
focus_state = {"entry": False}
def on_focus_in(event):
focus_state["entry"] = True
def on_focus_out(event):
focus_state["entry"] = False
entry.bind("<FocusIn>", on_focus_in)
entry.bind("<FocusOut>", on_focus_out)Then read |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Even if i have focussed on entry widget, i get false.
I printed them when I have widget selected and got output:
focussud- .!ctkentry.!entry
widget- .!ctkentry
They both are same still printing different values. How, help?
All reactions