Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Bug: Tk::Entry 804.027 validate?

by zentara (Archbishop)
on Jul 02, 2007 at 13:27 UTC ( #624437=note: print w/replies, xml ) Need Help??

in reply to Bug: Tk::Entry 804.027 validate?

<2 cents> First of all, my immediate reaction is that using validate with textvariable, is asking for trouble..... but your point about existing scripts breaking is valid.

Validate is intended for inspecting the value of something entered into the Entry widget. Some tidbits from the perldoc:

The characters to be added (or deleted). This will be "undef" if validation is due to focus, explcit call to validate or if change is due to "-textvariable" changing.

So you have undef values poping in there, when textvariable change occurs.

In general, the textVariable and validateCommand can be dangerous to mix. If you try set the textVariable to something that the validateCommand will not accept it will be set back to the value of the entry widget. Using the textVariable for readonly purposes will never cause problems.

So my advice is to redesign your script, to check for values in another way, rather than relying on the validate callback.

Why design something to use something which may go undef? You could just as easily put the value-check in the button callback( or wherever you set $entryText ).

If you really want to pursue this, you should probably ask on where one of the Tk internals experts may know something. </2cents>

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Replies are listed 'Best First'.
Re^2: Bug: Tk::Entry 804.027 validate?
by strat (Canon) on Jul 07, 2007 at 09:39 UTC

    Hello zentara,

    The reason why I want to do it that way is Tk::EntryCheck. This module that allows you to control which chars may be entered and up to which lenght into a Tk::Entry widget. I wrote this module because I prefer preventing invalid or too many chars to letting the user insert everything and then checking it and rising errors and the like.

    Well, I now try to rewrite this module using Tie::Watch.

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8."

      Hi, the mention of Tie::Watch, triggered my memories of Tk::Trace( which may work better with Tk). It's only glitch, is that you need to pre-declare package Tk and add Tk::Trace. See Simple Tk Gauge

      I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://624437]
[erix]: hm zipfile-SQLite sounds useful, have you tried it already, Corion?
[erix]: and good morning (sorry :))

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2018-01-24 08:52 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (256 votes). Check out past polls.