TomSchimansky / TomSchimansky/CustomTkinter

Associating a tk.StringVar with CTkEntry erases placeholder text

Open
#650 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement information
Dominant language
Python
Stars
13.6k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Hello.

I have added StringVar to CTkEntry widget, using the textvariable parameter. I am then binding the key release event to a function. The idea being that as the user types, the characters are converted to uppercase:

        self.tk_new_db_account_name = tk.StringVar(master=self.frm_new_entry)
        self.ent_new_db_account_name = ctk.CTkEntry(master=self.frm_new_entry,
                                                    placeholder_text='Database username',
                                                    textvariable=self.tk_new_db_account_name)
        self.ent_new_db_account_name.grid(row=row, column=0, padx=default_padx, pady=default_pady)
        self.ent_new_db_account_name.bind("<KeyRelease>", self.db_account_caps)

In case it is relevant (unlikely), db_account_caps method looks like this:

    def db_account_caps(self, event):
        self.tk_new_db_account_name .set(self.tk_new_db_account_name .get().upper())

The capitalisation works, however this causes the 'Database username', placeholder text, to be ignored (or erased). If I remove the StringVar, the placeholder text reappears.

This is happening with CustomTkinter 4.6.3.

Is this a bug or am I missing something?

Thanks.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the CTkEntry example in CustomTkinter 4.6.3 with both textvariable and placeholder_text, then compare it with the version without StringVar. Check whether the placeholder remains visible while the KeyRelease callback uppercases the value; done means both behaviors work together.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.