John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:

If you're not familiar with the "combo box" in Windows, it's a list box that shows only the current selection in a one-line window, until a little arrow next to it is clicked and then it drops-down a multi-line list to choose from.

I want to have a text-entry blank with "history". I can type something in the blank as usual, or click the little arrow and pick from previous things I've typed there.

I can't find a combo-box in the Widget demo or the "Learning Perl/Tk" book. Is such a thing supplied in some form?

--John

Edit by tye, add P tags

Replies are listed 'Best First'.
Re: Perl/Tk "combo box" widget?
by jdtoronto (Prior) on Aug 11, 2003 at 21:22 UTC
    THe BrowseEntry is what you need.

    But it was not in Learning Perl/Tk - it is in Mastering Perl/Tk.

    The p[ackage documentation for it is rather sparse, Matering Perl/Tk has a little on it. You will need to do some digging to find much on this one.

    ...john

Re: Perl/Tk "combo box" widget?
by crazymanchu (Novice) on Aug 11, 2003 at 19:22 UTC
    Try using the BrowseEntry widget. I think that is what you are looking for.
Re: Perl/Tk "combo box" widget?
by graff (Chancellor) on Aug 12, 2003 at 03:11 UTC
    I've used something called "JComboBox" (on CPAN) -- it's a bit finicky, but quite flexible, and may offer some features that BrowseEntry doesn't. I had trouble installing it in 5.005, but it works fine with 5.8.0.

    (I noticed some strange behavior when I tried to assign a value to the widget's textvariable in a subroutine while the window happened to be iconified (not mapped) -- so I had to make sure to map/display the window before assigning the value. I might not be using a current version.)

Re: Perl/Tk "combo box" widget?
by Courage (Parson) on Aug 12, 2003 at 06:52 UTC
    I also tried to find "native" combobox in Tk, asked on perlTk mailing list and failed.

    Actually it was discussed in TCLCORE mailing list that most probably native combobox widget will be added in Tk versions 8.5.

    Currently, in my opinion, most close behaviour provides widget "ComboBox" from BWidget package of Tcl/Tk.
    There is no direct equivalent in perlTk, but it could be accessible via Tcl::Tk perl module (like any other Tcl/Tk widget).

    However this will probably be not acceptable for you, as long as coexistence of widgets in perlTk and Tcl::Tk is currently buggy.

    Courage, the Cowardly Dog

Re: Perl/Tk "combo box" widget?
by RMGir (Prior) on Aug 12, 2003 at 11:58 UTC
      Browsing thru the User Interfaces/Tk category on http://search.cpan.org, I came across Tk::ComboEntry

      Sounds good, but I was overwhelmed with the documentation! I will have to allocate some time to read it thoroughly. Like a femtosecond or three?

      ....john

        Hehe, yeah.

        On the plus side, though, there is comboentry.pl in the examples subdirectory, and it seems to cover the usage pretty well.
        --
        Mike

      For what you've described, BrowseEntry should be sufficient, and it's extremely easy to use.