in reply to Re^4: Question about embedded Tk::Canvas
in thread Question about embedded Tk::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();
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: Question about embedded Tk::Canvas
by emilbarton (Scribe) on Nov 20, 2013 at 19:39 UTC | |
by kschwab (Vicar) on Nov 20, 2013 at 19:54 UTC | |
by emilbarton (Scribe) on Nov 20, 2013 at 20:11 UTC | |
by emilbarton (Scribe) on Nov 22, 2013 at 07:04 UTC |
In Section
Seekers of Perl Wisdom