Spinbox widget breaks when I use backspace to delete all its contents
See original GitHub issueHi thanks a lot for this fantastic project, I’ve been learning to use it, and I really like it.
Recently I hit below error when I using a SpinBox and want to correct the actual value myself and set manually.
Let’s say spinbox, shows 500 as value and I wanted to set it to 1, or any other number, when you use back space key there, all is ok if you DO NOT delete all text(numbers) in there, when you delete last digit then this happens:
Traceback (most recent call last):
File "/Users/larrycastro/Documents/workspace/lab-constructor/./lab-constructor.py", line 1960, in <module>
tui_menu()
File "/Users/larrycastro/Documents/workspace/lab-constructor/./lab-constructor.py", line 1884, in tui_menu
rootWindow.mainloop()
File "/usr/local/lib/python3.10/site-packages/TermTk/TTkCore/ttk.py", line 113, in mainloop
self._mainLoop()
File "/usr/local/lib/python3.10/site-packages/TermTk/TTkCore/ttk.py", line 122, in _mainLoop
self._input.start()
File "/usr/local/lib/python3.10/site-packages/TermTk/TTkCore/TTkTerm/input.py", line 77, in start
self.key_process(stdinRead)
File "/usr/local/lib/python3.10/site-packages/TermTk/TTkCore/TTkTerm/input.py", line 155, in key_process
self.inputEvent.emit(kevt, mevt)
File "/usr/local/lib/python3.10/site-packages/TermTk/TTkCore/signal.py", line 123, in emit
slot(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/TermTk/TTkCore/ttk.py", line 128, in _processInput
self._key_event(kevt)
File "/usr/local/lib/python3.10/site-packages/TermTk/TTkCore/ttk.py", line 188, in _key_event
keyHandled = focusWidget.keyEvent(kevt)
File "/usr/local/lib/python3.10/site-packages/TermTk/TTkWidgets/spinbox.py", line 84, in keyEvent
return TTkLineEdit.keyEvent(self._lineEdit, evt)
File "/usr/local/lib/python3.10/site-packages/TermTk/TTkWidgets/lineedit.py", line 233, in keyEvent
self.textEdited.emit(self._text)
File "/usr/local/lib/python3.10/site-packages/TermTk/TTkCore/signal.py", line 123, in emit
slot(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/TermTk/TTkWidgets/spinbox.py", line 73, in _textEdited
self.setValue(int(text))
ValueError: invalid literal for int() with base 10: ''
I’m thinking to do a workaround at the valueChanged
to catch all there and prevent this exception… not sure if this can work…,
I also think this is a bug, because I just tried on your online sandbox, and I think it breaks (https://ceccopierangiolieugenio.github.io/pyTermTk/sandbox/sandbox.html) widgets at spinxbox field example.
Please let me know if you need any ohter info from me. Regards
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:9 (5 by maintainers)
Hi @ceccopierangiolieugenio,
I do apologize!, I’m sorry I found issue. it was totally my fault!
How i discovered this issue:
Do you remember I was trying to setup this to find out if I was able to capture exception (which I was ovbiusly wrong) because it will break anyway without your changes.
then I totally forgot to get rid of this…
I’m sorry for waste your time.
You can consider this bug fixed. Thank you for your patience and fast fix.
heheh, no worries,
Actually I was wondering if you used something like copy and paste to change the value since I think that some widgets are still not protected from ANSI escape codes or control chars i.e. “\t” “\n”.
Thanks