Search code examples
validationtcltkinter-entry

What is %P in Tcl?


I saw this code en Tcl:

entry .amount -validate key -validatecommand {
    expr {[string is int %P] || [string length %P]==0}
}

I know that it's an entry validation but, what does "%P" in that code? I was looking in the Tcl's doc but I didn't find nothing.

I think this is another way to do it but it has the same symbols:

proc check_the_input_only_allows_digits_only {P} {
    expr {[string is int P] || [string length P] == 0}
}
entry .amount \
    -validate key \
    -validatecommand {check_the_input_only_allows_digits_only %P}

Solution

  • The tcl-tk page for entry says

    %P

    The value of the entry if the edit is allowed. If you are configuring the entry widget to have a new textvariable, this will be the value of that textvariable.

    https://www.tcl.tk/man/tcl8.4/TkCmd/entry.html#M25