in reply to Tk BrowseEntry with only the arrow button visible?

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

Replies are listed 'Best First'.
Re^2: Tk BrowseEntry with only the arrow button visible?
by elef (Friar) on Dec 29, 2013 at 14:24 UTC
    Thanks, but this does the same as a couple of the above solutions: the listbox that pops up starts at the left edge of the screen and stretches all the way to the button.
    Screenshot

    I have looked at optionmenu before, but it displays the first or currently selected option on the button. I could see no obvious way of displaying a small blank button without text. I'll play with it though.