Re: Validating Entry in tkinter

2011-07-27 Thread Giacomo Boffi
Saul Spatz writes: > In tcl/tk an Entry widget can be set to validate its contents with > the validate option. [...] Can one do something like this in > tkinter? i read the thread and nobody mentioned the python mega widget (Pmw) toolkit, from whose docs i quote the following Pmw.EntryField()

Re: Validating Entry in tkinter

2011-07-25 Thread Malcolm Greene
Peter, > I think it doesn't matter whether you type in text, or insert it with Ctrl+V > or the middle mouse button. The validatecommand handler is always triggered. > I suspect achieving the same effect with Button/KeyPress handlers would > require significantly more work. Thank you! Malcolm -

Re: Validating Entry in tkinter

2011-07-25 Thread Peter Otten
pyt...@bdurham.com wrote: > How would your examples work with text being inserted or deleted via the > clipboard? > > Is there anything special that would have to happen for changes to a > widget's value as the result of one of these events? I think it doesn't matter whether you type in text, or

Re: Validating Entry in tkinter

2011-07-25 Thread python
Peter, How would your examples work with text being inserted or deleted via the clipboard? Is there anything special that would have to happen for changes to a widget's value as the result of one of these events? Thank you, Malcolm (not the OP) -- http://mail.python.org/mailman/listinfo/python-

Re: Validating Entry in tkinter

2011-07-25 Thread rantingrick
On Jul 25, 2:08 pm, Peter Otten <__pete...@web.de> wrote: > Terry Reedy wrote: > > On 7/25/2011 8:31 AM, Peter Otten wrote: > >> Saul Spatz wrote: > > is it possible to set an onkey handler, that will pass on > > valid keys? > > With validatecommand you can have tkinter provide the string that is b

Re: Validating Entry in tkinter

2011-07-25 Thread Peter Otten
Terry Reedy wrote: > On 7/25/2011 8:31 AM, Peter Otten wrote: >> Saul Spatz wrote: >> >>> That doesn't work, I'm being stupid, The user might type anywhere in >>> the >>> string, not just at the end. I need >>> >>> return all([c in '1234567890abcdefABCDEF ' for c in after]) > > If one wants to

Re: Validating Entry in tkinter

2011-07-25 Thread Terry Reedy
On 7/25/2011 8:31 AM, Peter Otten wrote: Saul Spatz wrote: That doesn't work, I'm being stupid, The user might type anywhere in the string, not just at the end. I need return all([c in '1234567890abcdefABCDEF ' for c in after]) If one wants to validate keystrokes, rather than the entire fi

Re: Validating Entry in tkinter

2011-07-25 Thread Saul Spatz
Thanks, that a great link. -- http://mail.python.org/mailman/listinfo/python-list

Re: Validating Entry in tkinter

2011-07-25 Thread Saul Spatz
Yes, the tuple is certainly easier to read. Thanks again. -- http://mail.python.org/mailman/listinfo/python-list

Re: Validating Entry in tkinter

2011-07-25 Thread Peter Otten
Saul Spatz wrote: > That doesn't work, I'm being stupid, The user might type anywhere in the > string, not just at the end. I need > > return all([c in '1234567890abcdefABCDEF ' for c in after]) Ah, you found out already. Here's what I've come up with in the meantime. I also changed the comman

Re: Validating Entry in tkinter

2011-07-25 Thread Saul Spatz
That doesn't work, I'm being stupid, The user might type anywhere in the string, not just at the end. I need return all([c in '1234567890abcdefABCDEF ' for c in after]) -- http://mail.python.org/mailman/listinfo/python-list

Re: Validating Entry in tkinter

2011-07-25 Thread Saul Spatz
Thanks so much, this is great. I want to validate that the user is entering a string appropriate for bytes.fromhex. Here's how I modified your validate funtion: def validate(before, after): print(before, "-->", after) #return after.isdigit() return after[-1] in '1234567890abcdefABC

Re: Validating Entry in tkinter

2011-07-25 Thread Wolfgang Meiners
Am 25.07.11 02:11, schrieb Saul Spatz: > In tcl/tk an Entry widget can be set to validate its contents with the > validate option. You have to give it a validatecommand (vcmd), which is a > tcl script that runs when some action triggers validation. Usually, the > script would use "percent subs

Re: Validating Entry in tkinter

2011-07-25 Thread Peter Otten
Saul Spatz wrote: > In tcl/tk an Entry widget can be set to validate its contents with the > validate option. You have to give it a validatecommand (vcmd), which is a > tcl script that runs when some action triggers validation. Usually, the > script would use "percent substitutions" so the scrip

Re: Validating Entry in tkinter

2011-07-24 Thread Saul Spatz
I want to interface to the native validation of tk. If you don't know what that is, you're unlikely to be able to help me. -- http://mail.python.org/mailman/listinfo/python-list

Re: Validating Entry in tkinter

2011-07-24 Thread rantingrick
On Jul 24, 7:11 pm, Saul Spatz wrote: > > Can one do something like this in tkinter? ‡ (1) First of all what exactly do you wish return? * an integer * a float * something else? (2) Is this input part of a modal or non-modal interface? For me, input validation should happen in *real* time an

Validating Entry in tkinter

2011-07-24 Thread Saul Spatz
In tcl/tk an Entry widget can be set to validate its contents with the validate option. You have to give it a validatecommand (vcmd), which is a tcl script that runs when some action triggers validation. Usually, the script would use "percent substitutions" so the script would be something lik