Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Tk:Canvas - Arc with an arrow?

by cmv (Chaplain)
on Oct 09, 2009 at 15:11 UTC ( #800307=note: print w/replies, xml ) Need Help??

in reply to Tk:Canvas - Arc with an arrow?

ELISHEVA++ liverpole++

Many, many thanks for your work on this problem. It was a delight for me to read through your responses first thing this morning!

ELISHEVA, your find-the-end-of-the-arc solution works great, in combination with liverpole's fantastic try-things-out-and-play-with-it-script, and the synergy between the two of you has helped educated me in this area quite a bit. Thanks for going all PerlMonks on this one. It's exactly what I needed.

In the mean time, I continued on with the bunch-o-lines solution, after posting this and came up with the final version attached here.

My guts are telling me that the right solution is to get Tk to add an arrow option on to the end of the canvas arc item (and possibly others). I've run this gauntlet a long time ago to add a Get/Delete Enhancement for Tk Text Widget, so maybe this would be a good long-term solution (opinions?).

In any case, thanks again for all the valuable help!


use strict; use warnings; use Tk; my $top = MainWindow->new; my $can = $top->Canvas()->pack(); my @offset = (100, 100); my $PI = atan2(1,1) * 4; my $max = 100; my $radius = 20; my $start=35; my $end=$max-22; # Generate list of line segments... my @coords; foreach my $i (1..$end) { my $radians = ($i+$start)*2*$PI/$max, $radius; my @nextXY = ( $radius * sin($radians), # X-val $radius * cos($radians), # Y-val ); push(@coords, @nextXY); } # Fix things for the arrowhead... $coords[-1] -= 2; # y $coords[-2] += 2; # x # Draw the line (arrowed arc)... my $l = $can->create('line', \@coords, -arrow=>'last'); $can->move($l, @offset); MainLoop;

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2016-10-22 19:47 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (297 votes). Check out past polls.