May-21-2023, 12:17 PM
Hi,
Would like to share a link to the complete solution: PasswordGeneratorGUI.
The SpinBox control proved particularly challenging to fine tune it to where I wanted to get it.
The up and down arrows always worked as expected but I was never able to easily manage if someone typed in an invalid string in the box. I was expecting that if someone typed in, dd, I could capture an onChange or onFocusLost event out of the box and take corrective action.
I found that pressing Tab did not cause the SpinBox to loose focus (even though the cursor would jump).
The lines below seem to have done the trick.
Another observation is that the name of the spinbox I define in python is different from that in Tcl/tk (widget) and I can't figure out how to get from the python name to the internal equivalent. Can one get to this via
With one spinbox the solution is manageable.
Thanks for any comments
Would like to share a link to the complete solution: PasswordGeneratorGUI.
The SpinBox control proved particularly challenging to fine tune it to where I wanted to get it.
The up and down arrows always worked as expected but I was never able to easily manage if someone typed in an invalid string in the box. I was expecting that if someone typed in, dd, I could capture an onChange or onFocusLost event out of the box and take corrective action.
I found that pressing Tab did not cause the SpinBox to loose focus (even though the cursor would jump).
The lines below seem to have done the trick.
self.root.bind('<Return>', self.reset_focus) self.root.bind('<Tab>', self.reset_focus)Still not sure whether it could have been achieved without the need to code them in (they are built into the tool).
Another observation is that the name of the spinbox I define in python is different from that in Tcl/tk (widget) and I can't figure out how to get from the python name to the internal equivalent. Can one get to this via
(self.root.register(self.ValidateIfNum),'%P', '[b]%W[/b]')?
With one spinbox the solution is manageable.
Thanks for any comments