From: Peter G. <pe...@pg...> - 2006-10-17 12:29:51
|
In the example below, I create a new Frame, where the frame definition is given in an xrc file. Normally, a new frame would give a HASH reference, whereas LoadFrame gives a SCALAR reference. So the question arises: I have some private data, var, that I would like to store in this class. How do I do it? $newFrame->{var} = $var fails because of the scalar reference. Thanks, Peter package MyFrame; use vars qw(@ISA); @ISA = qw(Wx::Frame); use Wx qw(:everything); use Wx::Event qw(:everything) ; sub new { my $xrc = Wx::XmlResource->new(); $xrc->InitAllHandlers(); $xrc->Load("appliance.xrc"); my $newFrame = $xrc->LoadFrame(undef,'ID_FRAME') ; my $tree = $newFrame->FindWindow('ID_TREECTRL_MENU') ; my $var = "Test Var" ; $newFrame->{var} = $var ; return $newFrame,; } |
From: Mark W. <ma...@ne...> - 2006-10-17 14:59:10
|
Although the last code would work as a hash ref. as you requested, a 'better' way to subclass would be as follows: sub new { my ($class) = @_; # instead of using the following # which would return a reference to a 'Wx::Frame' #my $newFrame = Wx::Frame->new; # use this to create a reference to MyFrame # which is a derived class of Wx::Frame my $newFrame = $class->SUPER::new; ... } > -----Original Message----- > From: wxp...@li... > [mailto:wxp...@li...] On Behalf > Of Peter Gordon > Sent: 17 October 2006 02:30 PM > To: wxp...@li... > Subject: [wxperl-users] Advice needed > > In the example below, I create a new Frame, where the frame > definition is given in an xrc file. Normally, a new frame > would give a HASH reference, whereas LoadFrame gives a SCALAR > reference. > > So the question arises: I have some private data, var, that I > would like to store in this class. How do I do it? > $newFrame->{var} = $var fails because of the scalar reference. > > Thanks, > > Peter > > package MyFrame; > use vars qw(@ISA); > > @ISA = qw(Wx::Frame); > > use Wx qw(:everything); > use Wx::Event qw(:everything) ; > > sub new { > my $xrc = Wx::XmlResource->new(); > $xrc->InitAllHandlers(); > $xrc->Load("appliance.xrc"); > > my $newFrame = $xrc->LoadFrame(undef,'ID_FRAME') ; > > my $tree = $newFrame->FindWindow('ID_TREECTRL_MENU') ; > my $var = "Test Var" ; > > $newFrame->{var} = $var ; > return $newFrame,; > } > > > > > -------------------------------------------------------------- > ----------- > Using Tomcat but need to do more? Need to support web > services, security? > Get stuff done quickly with pre-integrated technology to make > your job easier Download IBM WebSphere Application Server > v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057& > dat=121642 > _______________________________________________ > wxperl-users mailing list > wxp...@li... > https://lists.sourceforge.net/lists/listinfo/wxperl-users |
From: Mark W. <ma...@ne...> - 2006-10-17 15:36:02
|
Hi Peter, Whenever I load resources from XRC I use the 2 step creation process: my $newFrame = Wx::Frame->new; $xrc->LoadOnFrame($newFrame, undef,'ID_FRAME'); Hope this help Mark > -----Original Message----- > From: wxp...@li... > [mailto:wxp...@li...] On Behalf > Of Peter Gordon > Sent: 17 October 2006 02:30 PM > To: wxp...@li... > Subject: [wxperl-users] Advice needed > > In the example below, I create a new Frame, where the frame > definition is given in an xrc file. Normally, a new frame > would give a HASH reference, whereas LoadFrame gives a SCALAR > reference. > > So the question arises: I have some private data, var, that I > would like to store in this class. How do I do it? > $newFrame->{var} = $var fails because of the scalar reference. > > Thanks, > > Peter > > package MyFrame; > use vars qw(@ISA); > > @ISA = qw(Wx::Frame); > > use Wx qw(:everything); > use Wx::Event qw(:everything) ; > > sub new { > my $xrc = Wx::XmlResource->new(); > $xrc->InitAllHandlers(); > $xrc->Load("appliance.xrc"); > > my $newFrame = $xrc->LoadFrame(undef,'ID_FRAME') ; > > my $tree = $newFrame->FindWindow('ID_TREECTRL_MENU') ; > my $var = "Test Var" ; > > $newFrame->{var} = $var ; > return $newFrame,; > } > > > > > -------------------------------------------------------------- > ----------- > Using Tomcat but need to do more? Need to support web > services, security? > Get stuff done quickly with pre-integrated technology to make > your job easier Download IBM WebSphere Application Server > v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057& > dat=121642 > _______________________________________________ > wxperl-users mailing list > wxp...@li... > https://lists.sourceforge.net/lists/listinfo/wxperl-users |
From: Peter G. <pe...@pg...> - 2006-10-18 08:14:58
|
Hi Mark, This works nicely, but as far as I can see is totally undocumented. Peter On Tue, 2006-10-17 at 15:42 +0200, Mark Wardell wrote: > Hi Peter, > > Whenever I load resources from XRC I use the 2 step creation process: > > my $newFrame = Wx::Frame->new; > $xrc->LoadOnFrame($newFrame, undef,'ID_FRAME'); > > Hope this help > Mark > > > -----Original Message----- > > From: wxp...@li... > > [mailto:wxp...@li...] On Behalf > > Of Peter Gordon > > Sent: 17 October 2006 02:30 PM > > To: wxp...@li... > > Subject: [wxperl-users] Advice needed > > > > In the example below, I create a new Frame, where the frame > > definition is given in an xrc file. Normally, a new frame > > would give a HASH reference, whereas LoadFrame gives a SCALAR > > reference. > > > > So the question arises: I have some private data, var, that I > > would like to store in this class. How do I do it? > > $newFrame->{var} = $var fails because of the scalar reference. > > > > Thanks, > > > > Peter > > > > package MyFrame; > > use vars qw(@ISA); > > > > @ISA = qw(Wx::Frame); > > > > use Wx qw(:everything); > > use Wx::Event qw(:everything) ; > > > > sub new { > > my $xrc = Wx::XmlResource->new(); > > $xrc->InitAllHandlers(); > > $xrc->Load("appliance.xrc"); > > > > my $newFrame = $xrc->LoadFrame(undef,'ID_FRAME') ; > > > > my $tree = $newFrame->FindWindow('ID_TREECTRL_MENU') ; > > my $var = "Test Var" ; > > > > $newFrame->{var} = $var ; > > return $newFrame,; > > } > > > > > > > > > > -------------------------------------------------------------- > > ----------- > > Using Tomcat but need to do more? Need to support web > > services, security? > > Get stuff done quickly with pre-integrated technology to make > > your job easier Download IBM WebSphere Application Server > > v.1.0.1 based on Apache Geronimo > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057& > > dat=121642 > > _______________________________________________ > > wxperl-users mailing list > > wxp...@li... > > https://lists.sourceforge.net/lists/listinfo/wxperl-users > > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > wxperl-users mailing list > wxp...@li... > https://lists.sourceforge.net/lists/listinfo/wxperl-users |