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

Question about embedded Tk::Canvas

by emilbarton (Scribe)
on Nov 20, 2013 at 11:35 UTC ( #1063502=perlquestion: print w/ replies, xml ) Need Help??
emilbarton has asked for the wisdom of the Perl Monks concerning the following question:

Hello, in Cstracker I have canvases embedded in a TableMatrix. I can get each canvas object this way:

 my $canvas =  $CstObj->{'matrix'}->windowCget("$tracknumber,1" , '-window');

However if I do:

 $canvas->scale("all",0,0,0.5,0.5);

nothing happens, although it should normally scale to half its size. Is there a way to have such an embedded canvas react correctly to this command?

Thanks in advance.

(https://github.com/emilbarton/Cstracker)

Update: When I do:

 $canvas->configure( -bg => "green" );

the command is correctly executed. But the first instruction above yields the following error:

 Tk::Error: bad window path name "all" at cstracker.pl line 1820.

I can't reproduce the error in a simpler script where I don't need to obtain the embedded canvas from TableMatrix->windowCget().

Comment on Question about embedded Tk::Canvas
Select or Download Code
Re: Question about embedded Tk::Canvas
by kschwab (Priest) on Nov 20, 2013 at 16:56 UTC
    Are you sure $canvas is actually a "Canvas"? Can you add print ref($canvas) . "\n"; and see what it prints out?
      This is the problem actually, my $canvas turned to a Tk::Frame in the process. In the simpler script with the same lines of code, even with

       $canvas =  $Matrix->windowCget("$tracknumber,1" , '-window')

      it remains a Canvas object.

       bless $canvas, "Tk::Canvas"

      doesn't help.
        Seems odd that it would turn into a Frame. I suspect the Canvas is just packed in that frame. Try $widget->children on the Frame, and I bet there's a Canvas there.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1063502]
Approved by hdb
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (15)
As of 2014-07-25 17:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (174 votes), past polls