isync has asked for the wisdom of the Perl Monks concerning the following question:

Monks,

I am new to Wx and currently I am stuck, while trying to hide() a section of an app.

I've got a $this->{tab2}->{maingrid} = Wx::FlexGridSizer->new(1, 3, 0, 0); inside a notebook. In cell 2 of the FlexGridSizer I have a ListCtrl. Based on the selection in the ListCtrl I am showing data in cell 3 of the sizer.

Cell 3 is of type $this->{tab2}->{sizer_right} = Wx::BoxSizer->new(wxVERTICAL); Now when I try to do
$this->{tab2}->{sizer_right}->Show(0); $this->Layout();
or with the shorthand Hide()
$this->{tab2}->{sizer_right}->Hide(); $this->Layout();
the app complains that it is "unable to resolve overloaded method for Wx::Sizer::Hide"

Replies are listed 'Best First'.
Re: WxPerl: Hide() a GridSizer?
by dirving (Friar) on Jul 09, 2008 at 05:33 UTC

    Check the documentation for Wx::Sizer again. Since it doesn't inherit from Wx::Window, its Hide method works a bit differently than a normal window. There are three different method signatures listed for the Hide method:

    bool Hide(wxWindow* window, bool recursive = false) bool Hide(wxSizer* sizer, bool recursive = false) bool Hide(size_t index)

    Since they all take one or more arguments, the error you are getting means that the binding couldn't pick between the available methods because none of them match your method call.

    I'm not sure exactly what you are trying to do so I can't tell you which set of arguments you want to use, but hopefully this will point you in the right direction.

    -- David Irving
Re: WxPerl: Hide() a GridSizer?
by pc88mxer (Vicar) on Jul 09, 2008 at 06:08 UTC
    I think you need to supply an additional argument to the Hide method. It's signature is ->Hide($obj [,$bool]) where $obj can be a window, sizer or an integer.

    Hide() is simply a convenience method for calling Show() with a show argument of false.

    The methods Hide and Show affect objects managed by the sizer. I don't believe the sizer itself has any graphical presence on the screen.

    For more details, see the wxSizer C++ documentation.

      You two indeed pointed me into the right direction! It's now working:

      The method need an additional argument. As first, I pass in which "base" object I am operating on "$this->{tab2}->{maingrid}->", then I tell Wx through the next (needed!) argument, which sub-part of this object it should hide. So I changed my strategy and now I am operating on the 3-column Sizer called maingrid, of which I hide the third column:

      $this->{tab2}->{maingrid}->Hide(2);

      (the hint at $bool and at that "Hide and Show affect objects managed by the sizer." was invaluable!)