Re: Destructors eg wxBitmap::~wxBitmap
Steve Cookson wrote: Hi, I can't see any obvious samples that tell you how the Perl syntax works for removing an element, like a bitmap, a textctrl or a button. Any pointers would be welcome. For all classes derived from wxWindow you can use -Destroy. Most other classes (including wxBitmap) do not need to be explicitly destroyed (the ones that do should have a note detailing it). HTH, Mattia
Re: Destructors
Steve Cookson wrote: Hi, Thanks to everyone for their help. Here is an answer that works: $self-{Notebook_tab_1}-DestroyChildren(); $self-{Notebook}-RemovePage(0); Doing it like this will leak the page object; unless you later reuse the window in Notebook_tab_1, the correct solution is either: $self-{Notebook}-DeletePage(0); or $self-{Notebook}-RemovePage(0); $self-{Notebook_tab_1}-Destroy(); Regards, Mattia
RE: Destructors
Hi Andri, Thanks for this. So my frame is called $self, and I have a TextCtrl on it called $self-{Field_Txt}. I tried to do: DESTROY($self-{Field_Txt}); . . . . . sub DESTROY{ } but it doesn't work. Maybe because I am only trying to delete part of an object, I should use a different command. Regards Steve -Original Message- From: Andri Möll [mailto:an...@dot.ee] Sent: 07 August 2009 13:53 To: Steve Cookson Cc: wxperl-users Subject: Re: Destructors On Fri, 2009-08-07 at 13:23 -0300, Steve Cookson wrote: Hi Guys, Does anyone know what the correct syntax for a Perl destructor is, if I want to remove a field, sizer or tab from a pane? Any suggestions welcome! Regards Steve Use the DESTROY subroutine with your Perl blessed object and invoke the appropriate method on your panel/sizer. wxSizer has Detach, wxWindow has Destroy and so on. Both the online WxWidgets' manual page at http://docs.wxwidgets.org/trunk/index.html and the perlobj(1) manual page might help you. Andri
RE: Destructors
Hi, Thanks to everyone for their help. Here is an answer that works: $self-{Notebook_tab_1}-DestroyChildren(); $self-{Notebook}-RemovePage(0); Regards Steve -Original Message- From: Steve Cookson [mailto:steve.cook...@sca-uk.com] Sent: 07 August 2009 14:31 To: wxperl-users@perl.org Cc: 'Andri Möll' Subject: RE: Destructors Hi Andri, Thanks for this. So my frame is called $self, and I have a TextCtrl on it called $self-{Field_Txt}. I tried to do: DESTROY($self-{Field_Txt}); . . . . . sub DESTROY{ } but it doesn't work. Maybe because I am only trying to delete part of an object, I should use a different command. Regards Steve -Original Message- From: Andri Möll [mailto:an...@dot.ee] Sent: 07 August 2009 13:53 To: Steve Cookson Cc: wxperl-users Subject: Re: Destructors On Fri, 2009-08-07 at 13:23 -0300, Steve Cookson wrote: Hi Guys, Does anyone know what the correct syntax for a Perl destructor is, if I want to remove a field, sizer or tab from a pane? Any suggestions welcome! Regards Steve Use the DESTROY subroutine with your Perl blessed object and invoke the appropriate method on your panel/sizer. wxSizer has Detach, wxWindow has Destroy and so on. Both the online WxWidgets' manual page at http://docs.wxwidgets.org/trunk/index.html and the perlobj(1) manual page might help you. Andri