G'day elef,

From your description, it sounds like Tk::Optionmenu is what you're after. If you look in the widget demo, you'll see examples under "Menus: 3. Menubuttons.": there's sample code for Optionmenu() as well as a native_optionmenu() subroutine — one of these should be suitable.

However, if you really must use Tk::BrowseEntry, this seems to do what you want:

#!/usr/bin/env perl use strict; use warnings; use Tk; use Tk::BrowseEntry; my $mw = MainWindow->new; $mw->geometry('300x400+50+50'); my $ctrl_F = $mw->Frame->pack(-side => 'bottom'); $ctrl_F->Button(-text => 'Exit', -command => sub { exit })->pack; my $app_F = $mw->Frame->pack(-side => 'top', -fill => 'both', -expand +=> 1); my $be_var; my $be = $app_F->BrowseEntry(-variable => \$be_var); $be->insert(end => "Option $_") for 1 .. 9; $be->pack; $be->Subwidget('entry')->packForget; MainLoop;

The entry box never appears.

The listbox doesn't shift to the left (which you mentioned in another part of this thread). The default -side for pack() is 'left': perhaps look at whatever you've used for this.

I wasn't entirely sure what you meant by "I just want the arrow button to be visible until it's clicked.". I'm on a *nix system: when the listbox appears, it covers the button. When I specified -style => 'MSWin32', the listbox appeared just below the button; with -style => 'unix', it returned to my OS's default of covering the button: perhaps consider that setting to get the look-and-feel you're after.

-- Ken


In reply to Re: Tk BrowseEntry with only the arrow button visible? by kcott
in thread Tk BrowseEntry with only the arrow button visible? by elef

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.