TomSchimansky / TomSchimansky/CustomTkinter
CTkEntry raises a TclError when using IntVar or DoubleVar
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 13.6k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
CTkEntry raises an error when you use IntVar or DoubleVar as a textvariable
customtkinter: 5.0.0
OS: Windows 10
Steps To Reproduce
- Run the below code in a python file.
- Enter any character that is not a number ex: "Hello, World"
- A TclError gets thrown every time you add or remove a character.
Observed Results
- Only effects the IntVar and DoubleVar.
- Throws the error when you remove or add characters.
- Entering a valid value (integer for IntVar and float for DoubleVar) does not throw an error.
- If you remove
0from the entry box it will raise the error
Code:
from customtkinter import CTk, CTkEntry
import tkinter
root = CTk()
root.minsize(200,200)
var1 = tkinter.IntVar()
var2 = tkinter.IntVar()
entry1 = CTkEntry(root, textvariable=var1) # Raises an error
entry1.pack()
entry2 = tkinter.Entry(root, textvariable=var2) # Does not raise an error
entry2.pack()
root.mainloop()
Error:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\1589l\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 570, in get
return self._tk.getint(value)
_tkinter.TclError: expected integer but got "hello, worl"
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\1589l\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1921, in __call__
return self.func(*args)
File "C:\Users\1589l\AppData\Local\Programs\Python\Python310\lib\site-packages\customtkinter\windows\widgets\ctk_entry.py", line 116, in _textvariable_callback
if self._textvariable.get() == "":
File "C:\Users\1589l\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 572, in get
return int(self._tk.getdouble(value))
_tkinter.TclError: expected floating-point number but got "hello, worl"
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
Reproduce the issue with the provided IntVar and DoubleVar examples, then inspect customtkinter/windows/widgets/ctk_entry.py at _textvariable_callback. Compare its behavior with tkinter.Entry when invalid text is entered or removed; done means those edits no longer raise the reported TclError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100