TomSchimansky / TomSchimansky/CustomTkinter
Associating a tk.StringVar with CTkEntry erases placeholder text
Nobody has claimed this yet.
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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