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

Re^3: Question about embedded Tk::Canvas

by kschwab (Priest)
on Nov 20, 2013 at 18:55 UTC ( #1063576=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Question about embedded Tk::Canvas
in thread Question about embedded Tk::Canvas

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.


Comment on Re^3: Question about embedded Tk::Canvas
Re^4: Question about embedded Tk::Canvas
by emilbarton (Scribe) on Nov 20, 2013 at 19:02 UTC
    Well I have

    Tk::Canvas=HASH(0x3071f58) Tk::Scrollbar=HASH(0x36db080) Tk::Frame=HASH(0x36db608)


    but the canvas would rather be a child of the matrix. I check that.
Re^4: Question about embedded Tk::Canvas
by emilbarton (Scribe) on Nov 20, 2013 at 19:13 UTC
    The ancestors from the main window are:

    $tracker_window = MainWindow->new.. $TrackBook = $tracker_window->NoteBook.. $TrackTabs{'Tracks'} = $TrackBook.. $Matrix = $TrackTabs{'Tracks'}->Scrolled.. $canvas = $Mainwin->Scrolled('Canvas')->grid.. my $real = $canvas->Subwidget("canvas"); # for bindings.. $CstObj->{'matrix'}->windowConfigure( "$i,1", -window => $canvas )..
      Right. So your issue is retrieving a reference to the canvas object. The easiest approach would probably be to store a reference to it when you create it. You seem to be creating a module anyway...so perhaps something like:
      package YourPackage; use strict;use warnings; use Tk; use Tk::Canvas; sub new { my $class = shift; my $self = bless {}, $class; my $mw = MainWindow->new(); $self->{'mainwin'}=$mw; $self->{'mycanvas'}=$mw->Canvas(); return $self; } sub getcanvas { my $self=shift; printf "Returning a %s\n",ref($self->{'mycanvas'}); return $self->{'mycanvas'} } package main; my $YP = YourPackage->new(); my $canvas=$YP->getcanvas();
        Ok, it seems quite a bit of a modification on my script. I don't understand why retrieving a reference aftewards should disturb but I'll apply this solution.

        Thank you very much for your help.
Re^4: Question about embedded Tk::Canvas
by emilbarton (Scribe) on Nov 20, 2013 at 19:17 UTC
    I have also a loop to destroy canvases in refresh, it might be faulty:

    for (my $n = 0; $n < $Maxobj; $n++ ){ my $canvas = $CstObj->{'matrix'}->windowDelete("$n,1"); } ## should delete embedded widgets in canvas track too (I hope).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2014-12-25 05:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls