in reply to Perl/TK get the Button's text
here is an example, you can either use the widgets ref and call cget on it or store the text instead.
Cheers, Christoph#!/usr/bin/perl use Tk; use strict; use warnings; my $mw = tkinit; my @buttons; for my $i(0..5){ push @buttons, $mw->Button(-text => $i, -command => sub{ print "pressed $i\n"; # or use the widget: print "pressed ", $buttons[$i]->cget('-text'), "\n"; })->pack; } MainLoop();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl/TK get the Button's text
by Anonymous Monk on Jun 03, 2009 at 16:47 UTC | |
by lamprecht (Friar) on Jun 03, 2009 at 20:17 UTC |