Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: perl/tk changing button commands

by Improv (Pilgrim)
on Apr 22, 2003 at 17:30 UTC ( [id://252324]=note: print w/replies, xml ) Need Help??

in reply to perl/tk changing button commands

Some comments
  • I doubt you really mean to be adding all those new buttons everytime you click 'next', right? You might want to read up about how the Tk event loop works.
  • You had the syntax for -command incorrect. You either pass it an anonymous subroutine (as in the $button2 example below) or a code reference, with \&
See below for corrected code.
use warnings; use Tk; sub one; my $main = MainWindow->new; my $button; my $button2; my $label1; $label1 = $main->Text ( '-width'=>'50')->pack; $button = $main->Button( -text=>'next', -command=>\&one)->pack; $button2 = $main->Button( -text=>'quit', -command=>sub{exit;})->pack; our $foo = "0"; MainLoop; sub one { my $talk="Hey, that was click $foo\n"; $foo++; $label1 -> insert('1.0',$talk); }

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://252324]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-05-26 00:27 GMT
Find Nodes?
    Voting Booth?

    No recent polls found