CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

CTkEntry focus not working

Open kdc1919 opened this issue 2 years ago • 3 comments

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()

kdc1919 avatar Sep 18 '22 19:09 kdc1919

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!

TomSchimansky avatar Sep 18 '22 19:09 TomSchimansky

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 avatar Sep 18 '22 20:09 kdc1919

@kdc1919 you can use the .focus_force() as a workaround now.

snoo-snoo avatar Nov 02 '22 01:11 snoo-snoo

Focus methods are now implemented with version 5.0.0.

TomSchimansky avatar Dec 02 '22 22:12 TomSchimansky

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!

JaredTweed avatar Feb 23 '23 23:02 JaredTweed

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 ??!

JonasAkka avatar Dec 05 '23 22:12 JonasAkka

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()

ingMychal avatar Dec 07 '23 17:12 ingMychal

same still not fixed i guess

LugawPlain avatar Apr 04 '24 16:04 LugawPlain