It runs, but when I click on one of the healthboxes drawn it doesn't do anything.use strict; use Tk; use Tk::DialogBox; #Character Variables. my $name = "Na"; my $health = "HP"; my $morality = "Mo"; my $willpower = "WP"; my $potency = "Po"; my $resource = "Re"; my $target = 0; # MainWindow my $mwin = new MainWindow(-background=>'black'); #Button for adding character information my $chrb = $mwin->Button(-text=>'Add Character',-activeforeground=>'bl +ack', -activebackground=>'green',-foreground=>'green',-backgroun +d=>'black', -command=>\&charadd) -> pack(-anchor=>'w'); #Canvas, which character info is drawn on. my $canv = $mwin->Scrolled('Canvas',width=>600,height=>600,-background +=>'black',-confine=>0) -> pack(); $canv->createLine(0,20,600,20,-fill=>'green'); #DialogBox, for when a new character is added. my $diag = $mwin->DialogBox(-title=>'Add Character',-buttons=>['Ok','C +ancel'], -default_button=>'Ok'); $diag->add('Entry',-textvariable=> \$name) -> pack(); $diag->add('Entry',-textvariable=> \$morality) -> pack(); $diag->add('Entry',-textvariable=> \$willpower) -> pack(); $diag->add('Entry',-textvariable=> \$potency) -> pack(); $diag->add('Entry',-textvariable=> \$resource) -> pack(); $diag->add('Entry',-textvariable=> \$health) -> pack(); Tk::MainLoop; #Maintain GUI. $canv->bind('<current>','<Button-1>', =>\&damage); our $charc = 0; sub charadd() { ++$charc; $canv->createText(20,($charc*60)+10,-text=>$charc,-fill=>'green'); $diag->Show(); $canv->createText(40,($charc*60)+10,-text=>$name,-fill=>'green'); $canv->createText(160,($charc*60)+10,-text=>"Po: $potency",-fill=> +'green'); $canv->createText(220,($charc*60)+10,-text=>"WP: $willpower",-fill +=>'green'); $canv->createText(280,($charc*60)+10,-text=>"Re: $resource",-fill= +>'green'); $canv->createText(360,($charc*60)+10,-text=>"Mo: $morality",-fill= +>'green'); for (my $i = 1; $i <= $health; $i++) { $canv->createRectangle($i*30,($charc*60)+20,($i*30)+20,($charc +*60)+40, -fill=>'green',-tag=>'hpbox'); } } sub damage() { }
In reply to Tk Canvas Item Bind by JadedAegis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |