Is there a simpler solution?

DIY :)

Is there a different drop-down list widget that is displayed as only a button?

Don't know , maybe, would investigate tk j ... Tk::JFileDialog Tk::JComboBox Tk::JBrowseEntry ...

Is there a simpler solution?

Looking at a widgetdump, you can do  $jb1 ->Subwidget('entry')->packForget ; that works to hide it

this messes up the width, so you'd have to bind the button to pack before invoking original button handler

{ my $parent = $jb1 ; my $arrow = $jb1 ->Subwidget('arrow'); my $callback = $arrow->bind('<Button-1>'); $jb1 ->Subwidget('entry')->packForget; $arrow->bind('<Button-1>', [ sub { my( $button, $jbl, $callbackarray ) = @_; warn "fucking @_\n"; warn "button($button) jbl($jbl) callback($callback)\n"; $jbl->Subwidget('entry')->pack(-side => "right", -fill => +'x', -padx => 0, -pady => 0, -expand => 1); my( $cb, @args ) = @$callbackarray; $cb->(@args); }, $parent, $callback, ] ); }

This is only half ... if anything it tells you what to edit in Tk::JBrowseEntry :D in Tk::BrowseEntry::SetBindings ...

update:

#!/usr/bin/perl -- use strict; use warnings; use Tk; use Tk::BrowseEntry; Main( @ARGV ); exit( 0 ); sub Tk::BrowseEntry::Popdown { my ($w) = @_; if ( $w->{'_BE_savefocus'} && Tk::Exists( $w->{'_BE_savefocus'} ) +) { $w->{'_BE_savefocus'}->focus; delete $w->{'_BE_savefocus'}; } if ( $w->{'_BE_popped'} ) { my $c = $w->Subwidget('choices'); $c->withdraw; $w->grabRelease; if ( ref $w->{'_BE_grabinfo'} eq 'CODE' ) { $w->{'_BE_grabinfo'}->(); delete $w->{'_BE_grabinfo'}; } $w->{'_BE_popped'} = 0; $w->Subwidget('entry')->packForget; } } sub Tk::BrowseEntry::BtnDown { my ($w) = @_; return if $w->cget( '-state' ) eq 'disabled'; if ($w->{'_BE_popped'}) { $w->Popdown; $w->{'_BE_buttonHack'} = 0; } else { $w->Subwidget('entry')->pack(-side => 'right', -fill => 'x', - +expand => 1); $w->update; $w->PopupChoices; $w->{'_BE_buttonHack'} = 1; } } sub Main { my $mw = tkinit(); my $var = 'lelabel'; my $b = $mw->BrowseEntry(-label => "Label", -variable => \$var); $b->insert("end", "opt1"); $b->insert("end", "opt2"); $b->insert("end", "opt3"); $b->Subwidget('entry')->packForget; $b->pack; MainLoop; }

In reply to Re: Tk BrowseEntry with only the arrow button visible? ( override Tk::BrowseEntry::SetBindings / sub Tk::JBrowseEntry::Popdown) by Anonymous Monk
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.