Bloodelf has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks.
I have a script, which uses a Tk::BrowseEntry widget to select an option from a list which not only has default values, but can also be appended. The widget is usually set to ‘read only’ but a new entry can be added by clicking a button which runs the following sub:
sub add_button_click{$entryvariable = ""; $mybrowseentry->focus; $mybrowseentry->configure(-state => 'normal'); }
The user can then input whatever they want, but when they have finished (or click off the entry box) I need to be able to change the state back to be read only.
any ideas???

To make my life easier, I could really do with knowing how to check the status of any of the variables,widgets etc. at ANY point in time, and not just when a button or something is pressed - is this possible with TK???
Many thanks

Replies are listed 'Best First'.
Re: Tk::BrowseEntry help
by {NULE} (Hermit) on Mar 27, 2002 at 17:27 UTC
    Hey Bloodelf,

    I think what you are asking for is a polling function. Check the docs on Tk::after.

    Basically to call a function once after a given interval do a:

    $id = $widget->after(milliseconds, [ &callback, \$var ]);
    This will call that callback once after X milliseconds. To do a call back repeatedly use repeat instead of after:
    $id = $widget->repeat(milliseconds, [ &callback, \$var ]);
    This will call the callback after every X milliseconds. (Above are examples from the docs.) Hope that helps,
    {NULE}
    --
    http://www.nule.org
      Excellent......
Re: Tk::BrowseEntry help
by rbc (Curate) on Mar 27, 2002 at 16:47 UTC
    To set the widgets state to readonly do this ...
    $mybrowseentry->configure( -state => 'readonly' );
    To get the "status" of widgets do this ...
    $widget->cget( 'state' );

    I hope that helps.