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

Hi Monks

I am new to perl tk.

1. Is there any way to restrict the user to enter in BrowseEntry. i.e i want to give the option of only selecting from the existing values

2. I come across terms like Button-1, Button-2. Upto Button-5 is valid. What does these represent. Any resources on this would also be helpful.

thanx in advance

Replies are listed 'Best First'.
Re: perl Tk
by castaway (Parson) on Jan 20, 2005 at 11:18 UTC
    1. You could add a -browsecmd callback to your BrowseEntry constructor, add use it to check that the entered value exists in the list, else delete it or otherwise give some error message. (Since the docs dont say, just experiement with this callback to see what it passes you, by running a print "@_\n"; at the top of it).

    You would probably be better off using a ListBox though.

    2. The elements that can be bound to are listed in the Tk::bind documentation.

    C.

Re: perl Tk
by Crian (Curate) on Jan 20, 2005 at 11:49 UTC

    Button-1, Button-2, ... are mouse buttons.

    Take a look at perldoc Tk::bind for more informations, just as castaway said.

Re: perl Tk
by jdtoronto (Prior) on Jan 20, 2005 at 19:38 UTC
    1.. In your BrowseEntry constructor specify -state => readonly.

    That widget can have three modes, normal - select form the popup list or enter directly, readonly - must choose a value fomr the list or disabled - does nothing.

    2.. See Tk::bind documentation.

    jdtoronto