in reply to Tk BrowseEntry with only the arrow button visible?
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Tk BrowseEntry with only the arrow button visible? ( override Tk::BrowseEntry::SetBindings / sub Tk::JBrowseEntry::Popdown)
by elef (Friar) on Dec 23, 2013 at 09:06 UTC | |