Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I don't know the source of your error message, but in general on a Tk Canvas, images and text fonts won't scale automatically. For instance this script shows scale working error free with the "all" tag, but the image and text must be manually zoomed, which I did not do. So the real question for me is, how did your image actually zoom as you claim The image zooms, but the objects don't change at all.

Please show a simple working example otherwise.

#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::JPEG; my $width = 600; my $height = 600; my $mw = MainWindow->new( -background => 'lightgreen' ); $mw->geometry( $width . 'x' . $height . '+40+40' ); # first create a canvas widget my $canvas = $mw->Scrolled('Canvas', width => $width/1.3, height => $h +eight/1.3)->pack(); my $eightim = $mw->Photo(-data => get_img() ); my $one = $canvas->createOval(55, 20, 200, 190, -fill => 'blue', -outline=>'blue', -tags => ['blue'], -stipple => 'gray75', ); my $two = $canvas->createOval(105, 20, 250, 190, -fill => 'red', -outline=>'red', -tags => ['red'], -stipple => 'gray12', ); my $eight = $canvas->createImage( ($width * .5), ($height * .5) - 20, -image => $eightim, -anchor => 'center', -tags => ['8im'], ); my $testfont = $mw->Font(-family=> 'Arial', -size => 24); my $text = 'This is some text'; $canvas->createText(50,50, -text => $text, -anchor => 'nw', -font => $testfont ); $canvas->createRectangle(47,47,290,87); my $ebutton = $mw->Button(-text => 'Exit', -command => 'Tk::exit')->pack(); my $sbutton = $mw->Button(-text => 'Scale', -command => sub{ $canvas->scale('all', 0, 0, 1.5, 1.5); $canvas->configure(-scrollregion=>[$canvas->bbox +("all")]); })->pack(); MainLoop(); ########################################### sub get_img{ my $ima8= '/9j/4AAQSkZJRgABAQEASABIAAD/4QAWRXhpZgAATU0AKgAAAAgAAAAAAAD//gAXQ3JlY +XRlZCB3 aXRoIFRoZSBHSU1Q/9sAQwAFAwQEBAMFBAQEBQUFBgcMCAcHBwcPCwsJDBEPEhIRDxEREx +YcFxMU GhURERghGBodHR8fHxMXIiQiHiQcHh8e/9sAQwEFBQUH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EhKT0BJ9QKZG3S/SbLpBLMNwtyJ73cFY4FKACVY+Q +6mg6F+ 2j6RsslcR+5d++g7q246C4U+RVyz5ZzWm0bUNHXB9LH6xXEWrl+kNFCffiB1IqtIGBgE4H +Lj9cfP jR68c8+FBYXaTs7XqhJnQbzJVIA3248hzfjq8k8PsE/HjSBnxJUGa9DmsrZksq3HELHFJH +11507u zxfpc61zLJKeLgg7q2Co5IQrI3fQEf3egri9o+0tMXS23htCUrlIW07jxKMbpPxOFY/lFA +pKKKKB o9nGY21qmdEWQlT8TeRnxKVA49iT0qYdoW2PzdJR5sdtSzCkguADOEKGCffd96R2nLvKsN +7jXaGr D0Ze+ATgLGMFJ8iOHWrN6U1NZNW2kqiuNLUpG7IiO43kZGCFJPNPyNBVTIxzHvR4cOfhT/ +v2xuwT ZKn7dNk2zfOS2kBbY9ASCB1rTaditljvpduN0lzkpIPdpQGkn15n5ig8HZutbzbNzvDiFJ +ZeKGGC R+LGSr/n51h2lZbfd2WCD95l15Q+A+yB/umTdLnYNH2NK5TkeBEYQUsspwCfyoT4n/01Wz +XOo5Oq NRP3WQC2lQDbLROe7bGcD5k+pNBwqKKKA5ZPlW6JIkRXUvxH3Y7qRlK2llJHoQRiiigk8H +aTrWI2 ENX15aR/GbQ6f6lJJ+dZydpmt5SVNqvi0Jxx7thtJ9wkEUUUEXnzptxfMmdLkSXVcCt5wr +V7k15/ 8UUUBRRRQf/Z'; return $ima8; } ####################################### __END__

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

In reply to Re: Tk: Scaling canvas objects by zentara
in thread Tk: Scaling canvas objects by perldough

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-20 01:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found