CustomTkinter
CustomTkinter copied to clipboard
CTkEntry focus not working
Good Day,
I was wondering if anyone else was having this same problem. I'm trying to focus set an entry box but it doesn't appear to work with CTkEntry boxes. Is anyone else having this same problem?
lbl_address_line_2 = ct.CTkLabel(lf_general_info, text="Address Line 2*:", anchor="e")
lbl_address_line_2.grid(column=2, row=1, sticky="e", padx=10)
self.value_address_line_2 = StringVar(self.receipt_printer_win, value="")
self.entry_address_line_2 = ct.CTkEntry(lf_general_info, corner_radius=5,
textvariable=self.value_address_line_2, width=200)
self.entry_address_line_2.grid(column=3, row=1, pady=10, sticky="we")
self.entry_address_line_2.focus_set()
It is just not implemented, when you call focus_set it is called on the frame the CTkEntry inherits from. But I will add this!
Good Day Tom,
Ahh I see. Thank you very much for the quick response. Do you know of any workaround I can use in the meantime?
Regards Kevin.
@kdc1919 you can use the .focus_force() as a workaround now.
Focus methods are now implemented with version 5.0.0.
I am not certain that it is working (at least for windows 11). Can you please double check this? Thank you. I am using 5.1.2
EDIT: Nevermind. it is working great!
hi i have trouble with my python programm using the CtkEntry, cause it doesn't lose the focus when i click out of the entry ??!
Hi @TomSchimansky , love your work! I am just getting familiar w/ Python/customtkinter and got stuck at .focus() method of CTkEntry widget. It does not seem to be working for me (my venv is running Python 3.11.5 + customtkinter 5.2.1).
When I run main.py the CTkEntry is not active, same result when using .focus_force().
In tkinter .focus_set()
worked just fine.
Am I missing something? Here is my code:
import customtkinter as Ctk
def create_ui():
root = Ctk.CTk()
root.title("Window")
root.geometry("800x900")
input_frame = Ctk.CTkFrame(root, fg_color="transparent" )
input_frame.pack()
search_entry = Ctk.CTkEntry(
input_frame,
width=450)
search_entry.grid(row=0, column=0, padx=20, pady=20)
search_entry.focus()
return root
if __name__ == "__main__":
root = create_ui()
root.mainloop()
same still not fixed i guess