Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: What would you guys recommend for generating graphic-based output?

by zentara (Archbishop)
on Jan 26, 2005 at 13:10 UTC ( [id://425192]=note: print w/replies, xml ) Need Help??


in reply to What would you guys recommend for generating graphic-based output?

Here is a simple Tk example. I've just put the row-col numbers in the cells, but you could load $cells{$row}{$col}{'data'} with your spreadsheet output and use that for the text. It is also possible to change fonts, cell colors, text color, etc. When you click the png-output button, be patient, it may take a second or 2.
#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::WinPhoto; use Tk::PNG; my $mw = tkinit; my $width = 500; my $height = 700; my $canv = $mw->Canvas(width => $width, height =>$height)->pack(); #set cell size adjustment my $x = 50; my $y = 20; my $rows = int( $height / $y + 1 ) - 1; #make it 0 based my $cols = int( $width / $x + 1 ) - 1; print "rows->$rows cols->$cols\n"; my %cells; foreach my $row ( 0 .. $rows ) { foreach my $col ( 0 .. $cols ) { $cells{$row}{$col}{'rect'} = $canv->createRectangle( $col * $x, $row * $y, $col * $x + $x, $row * $y + $y, #-width => 1, -outline => 'white', ); $cells{$row}{$col}{'text'} = $canv->createText( $col * $x + $x/2 , $row * $y + $y/2, -text => "$row - $col", -anchor => 'center', -fill => 'black', ); } } my $canvbutton = $mw->Button(-text=>'Canvas Capture', -command => \&canv_capture, )->pack; MainLoop; ########################################################## sub canv_capture{ my $image = $mw->Photo(-format => 'Window', -data => oct($canv->id) ); my $pathname = './canvas.'.time.'.png'; $image->write($pathname, -format => 'PNG'); } ##############################################################

I'm not really a human, but I play one on earth. flash japh
  • Comment on Re: What would you guys recommend for generating graphic-based output?
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-24 13:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found