What happens when you use -width and -height to resize the button?
--
Marc Dashevsky -- Remove '_' from address if replying by e-mail.
GeometryRequest doesn't work that well for this....and the -height option is
determined by the text size. So, you use an image instead !
#### Button Resizer ####
#!/usr/bin/perl
use Tk;
use Tk::Compound;
use strict;
my $multiplier=1;
my $mw=tkinit;
my $thinbutton = $mw->Button;
my $c = $thinbutton->Compound;
$c->Text(-text => "Slim Button");
$thinbutton->configure(-image => $c,-height=>$multiplier*10);
$thinbutton->pack(-side=>'left');
$mw->Scale(
-variable=>\$multiplier,
-from=>1,
-to=>5,
-command=>[\&resize_button,$thinbutton])->pack(-side=>'right');
MainLoop;
sub resize_button
{
my $b=shift;
$b->configure(-height=>$multiplier*10);
}
__END__
--
Jack D.
Remove '__' from address if replying by e-mail.
use Tk;
{
package Tk::foo;
use base qw(Tk::Frame);
Tk::Widget->Construct('foo');
use Tk::Compound;
sub Populate
{
my $mw = shift;
my $box = $mw->Listbox;
my $thinbutton = $mw->Button(-command => sub{
$box->insert('end','foo')});
my $c = $thinbutton->Compound;
$c->Text(-text => "Slim Button");
$thinbutton->configure(-image => $c,-height=>$multiplier*10);
my $adj = $mw->Frame(qw/-width 2 -bg black -borderwidth 1 -relief
sunken -cursor sb_h_double_arrow/)
->pack(qw/-fill y -side right -expand 1/);
$adj->bind('<B1-Motion>', sub{
my $pixels = $mw->pointerx - $mw->rootx - 8;
if ($pixels > 0) {
$thinbutton->configure(-width => $pixels);
$box->GeometryRequest($pixels, $box->height);
}
});
$thinbutton->pack(qw/-side top -fill x -expand 0/);
$box->pack(qw/-side bottom -fill both -expand 1/);
}
}
my $mw=tkinit;
$mw->foo->pack(qw/-side left fill both -expand 0/);
$mw->foo->pack(qw/-side left fill both -expand 0/);
MainLoop;
"Jack D." <goodc...@hotmail.com> wrote in message news:<rvuka.16363$B54.2...@news1.telusplanet.net>...
Hmm....your original post didn't say you were using GeometryRequest on a listbox
:-)
The point I was trying to make is to 'avoid' using GeometryRequest ... period.
You asked about resizing a button, to which I gave a possible solution (without
using GeometryRequest). A listbox, that is another problem altogether.
There may be a few options to consider.
1. Try the original Tk::Adjuster
2. Try using the 'form' geometry manager to lock the sides of the listbox and
adjuster to follow the button. Then only adjust the size of the button.
3. Yucky but possible - use fontMetrics to determine the character width needed
based on your button width.
Jack