Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Tk: Scaling canvas objects

by zentara (Archbishop)
on Jul 24, 2012 at 13:36 UTC ( [id://983408]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Tk: Scaling canvas objects
in thread Tk: Scaling canvas objects

I'll try out your code (assuming it's tested)

Yes, it's well tested standard code. If you want to zoom text, you can configure the font object to use a scaled up point size. Rebuilding the font, just as you rebuild a new image.

#!/usr/bin/perl use warnings; use strict; use Tk; require Tk::Font; #by originally by Chris Lamprecht my $MAIN = new MainWindow; my $canvas = $MAIN->Canvas()->pack(-expand => 'yes', -fill =>'both'); my $initial_fontsize = 24; my $scaling_factor = 1; my $l_text = "current scaling_factor : $scaling_factor"; my $helveticaStd = $MAIN->Font(-family=> 'Arial', -size => $initial_ +fontsize); my $text = 'This is some text'; $canvas->createText(50,50, -text => $text, -anchor => 'nw', -font => $helveticaStd); $canvas->createRectangle(47,47,290,87); for my$fac (0.8,1.2){ $MAIN->Button(-text => "Scale by $fac", -command => [\&scaling,$fac] )->pack; } $MAIN->Label(-textvariable=>\$l_text)->pack; MainLoop; sub scaling{ $scaling_factor *= $_[0]; $canvas->scale('all',0,0,$_[0],$_[0]); $helveticaStd->configure(-size=>$initial_fontsize * $scaling_factor +); $l_text = "current scaling_factor : $scaling_factor"; } __END__

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-20 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found