in reply to How to get the width/height of a Tk::Button widget?
#!/usr/bin/perl -l use strict; use warnings; use Tk; my $mw = tkinit(); my $button = $mw->Button( -text => 'Button', -width => 5, -height => 1, -command => sub { exit } )->pack(); $button->bind( '<ButtonPress-1>', \&buttonPress ); $mw->MainLoop(); sub buttonPress { my @queries = ( 'RootX: ' . $button->rootx, 'RootY: ' . $button->rooty, 'State: ' . $button->cget('-state'), 'Text: ' . $button->cget('-text'), 'Width: ' . $button->cget('-width'), 'Height:' . $button->cget('-height'), ); foreach my $query( @queries ) { print $query; } }
|
|---|