in reply to Re^2: Perl/TK get the Button's text
in thread Perl/TK get the Button's text
this was only meant to be an example on how the Button options can be used. In real world I'd keep data seperated from widgets wherever possible. Also if your data is dynamic I would prefer a Listbox or something similar over dynamically created buttons. That's what most people are used to. But this might well be my very personal taste ;)
Cheers, Christoph#!/usr/bin/perl use Tk; use strict; use warnings; my $mw = tkinit; my @buttons; my @data = qw/foo bar baz this that whatever /; for my $i(0..5){ push @buttons, $mw->Button(-text => $data[$i], -command => sub{ print "pressed $data[$i]\n"; print "pressed ", $buttons[$i]->cget('-text'), "\n"; })->pack; } MainLoop();
|
|---|