in reply to Printing a TK Canvas

You can look at the widget demo under "Canvas", and select "Simple 2D Plot", it has a button to print to printer. Copy the code. It goes something like this:
sub area_save { my($w, $pinfo) = @_; my($x1, $x2, $y1, $y2, $a); if($pinfo->{'areaX2'} != -1) { ($x1, $x2, $y1, $y2) = @$pinfo{'areaX1', 'areaX2', 'areaY1', 'areaY2'}; # slice ! ($x1, $x2) = @$pinfo{'areaX2', 'areaX1'} if $x2 <= $x1; ($y1, $y2) = @$pinfo{'areaY2', 'areaY1'} if $y2 <= $y1; $a = $w->postscript('-x' => $x1, '-y' => $y1, -width => $x2 - $x1, -height => $y2 - $y1); } else { $a = $w->postscript; } $SIG{'PIPE'} = sub {}; open(LPR, "| $pinfo->{'prcmd'}"); print LPR $a; close(LPR); } # end area_save

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re: Re: Printing a TK Canvas
by Anonymous Monk on Apr 18, 2004 at 16:39 UTC
    i hate to keep asking questions, but :P

    1) what are the 2 arguments passed to it ?
    my($w, $pinfo) = @_;
    i.e. which is the canvas, and what is the other thing ?

    2) This appears to use PIPE's ? im using windowsXP, I though pelr couyldnt use pipes outside of linux. Or is that just for the Printer module ?

    Thanks again :)