Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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:


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.


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 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().

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1063502]
Approved by hdb
Front-paged by Corion
[Corion]: A good morning and weekstart to you too, Discipulus!

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2018-06-25 07:16 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.