CustomTkinter
CustomTkinter copied to clipboard
root.focus_get() dont detect if the focus is on custom tkinter entrys .
import customtkinter
from tkinter import *
def test(event):
if root.focus_get() == custom_entry:
print("custom_entry")
elif root.focus_get() == ttk_entry:
print("ttk_entry")
root = customtkinter.CTk()
custom_entry = customtkinter.CTkEntry(root) #CTkEntry
custom_entry.pack()
ttk_entry = Entry(root) #ttk_entry
ttk_entry.pack()
root.bind("<Return>", test)
root.mainloop()
when I click on the ttk entry and press enter it print ----> "ttk_entry"
But when I do the same thing to the customtkinter.CTkEntry it print nothing .
Something is definitely firing though, as printing root.focus_get() itself returns .!ctkentry.!entry when you submit so it knows that a ctkentry is focused but doesn't return the name of which, may be fixed by #422?
Seems the fix won't work for the dev branch though due to some restructuring and a check to keep kwargs empty. I would not be surprised if this isn't something already being worked on though like with many parity issues.
I found a the solution which is simply by add .widget_type , like in my exemple insted of :
if root.focus_get() == custom_entry: ### dont work
i had to do custom_entry.entry like that :
if root.focus_get() == custom_entry.entry: ### work