# wxSizerItem show() method

**URL:** <https://www.ruby-forum.com/t/wxsizeritem-show-method/124389>\
**Category:** wxRuby\
**Created:** [December 28, 2007, 7:47am UTC](https://www.ruby-forum.com/t/wxsizeritem-show-method/124389 "2007-12-28T07:47:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ratkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bcef8e/32.png) [@ratkins](https://www.ruby-forum.com/u/ratkins)\
**Post date:** [December 28, 2007, 7:47am UTC](https://www.ruby-forum.com/t/wxsizeritem-show-method/124389/1 "2007-12-28T07:47:33Z")

</div>

It appears from the wx 2.8.7 documentation that a wxSizerItem has a  
show()  
method. But when I try to invoke it through wxruby, I get:

tasks.rb:56:in `do_btn3': undefined method`show’ for  
#SWIG::TYPE\_p\_wxSizerItem:0xb5eedf44 (NoMethodError)

Is this just something that hasn’t been added because people don’t  
manipulate wxSizerItems much, or is it something deeper than that? Or  
am I  
doing something stupid?

The reason this comes up is that I am trying to use spacers in a dynamic  
way, “collapsing” them with show(false) when needed.

Thanks,  
Bob

---

<div class="post-metadata">

**Author:** ![ratkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bcef8e/32.png) [@ratkins](https://www.ruby-forum.com/u/ratkins)\
**Post date:** [December 28, 2007, 9:11am UTC](https://www.ruby-forum.com/t/wxsizeritem-show-method/124389/2 "2007-12-28T09:11:06Z")

</div>

Hello Robert,

Actually, the best thing to do, is for you to use the Root Sizer, EG:  
BoxSizer, FlexGridSizer, Etc, etc, to utilize the #layout() method, to  
update the controls being displayed, and utilize the Window#show()  
method on  
the actual control, instead of the sizer item.

An example would be:

def on\_click\_hide()  
@my\_control.show(false)  
self.sizer.layout()  
end

This will cause the control to be hidden, and to call layout() to  
re-size  
all of the children controls that have been added to the Sizer.

L8ers,

Mario S.

---

<div class="post-metadata">

**Author:** ![ratkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bcef8e/32.png) [@ratkins](https://www.ruby-forum.com/u/ratkins)\
**Post date:** [December 28, 2007, 9:24am UTC](https://www.ruby-forum.com/t/wxsizeritem-show-method/124389/3 "2007-12-28T09:24:32Z")

</div>

On Dec 28, 2007 12:06 AM, Mario S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hello Robert,
> 
> Actually, the best thing to do, is for you to use the Root Sizer, EG:  
> BoxSizer, FlexGridSizer, Etc, etc, to utilize the #layout() method, to  
> update the controls being displayed, and utilize the Window#show() method on  
> the actual control, instead of the sizer item.

Mario,

If I am using the add() method on the sizer which adds a spacer, is  
there a  
control at all?

\*wxSizerItem[http://www.wxwidgets.org/manuals/stable/wx\_wxsizeritem.html#wxsizeritem](http://www.wxwidgets.org/manuals/stable/wx_wxsizeritem.html#wxsizeritem)  
\*\* _Add_(\*int \*_width_, \*int \*_height_, \*int \*_proportion = 0_, \*int  
\*_flag  
= 0_, \*int \*_border = 0_,  
_wxObject[http://www.wxwidgets.org/manuals/stable/wx\_wxobject.html#wxobject](http://www.wxwidgets.org/manuals/stable/wx_wxobject.html#wxobject)_  
\*_userData = NULL_);

Thanks,  
Bob

---

<div class="post-metadata">

**Author:** ![ratkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bcef8e/32.png) [@ratkins](https://www.ruby-forum.com/u/ratkins)\
**Post date:** [December 28, 2007, 8:46pm UTC](https://www.ruby-forum.com/t/wxsizeritem-show-method/124389/4 "2007-12-28T20:46:26Z")

</div>

Mario,

Thanks for your suggestions. I worked around this issue by using  
wxPanel as  
a “dummy” item in the sizer. Then I have something concrete to  
hide/show.

Thanks,  
Bob

---

<div class="post-metadata">

**Author:** ![ratkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bcef8e/32.png) [@ratkins](https://www.ruby-forum.com/u/ratkins)\
**Post date:** [December 28, 2007, 11:43am UTC](https://www.ruby-forum.com/t/wxsizeritem-show-method/124389/5 "2007-12-28T11:43:48Z")

</div>

Robert,

I don’t believe there is an actual control returned from #add() method  
that  
is utitlized to add a spacer. It is more then nothing an internal data  
structure in which to show that something occupies that space, but  
nothing  
is actually drawn for that space itself. If you need to dynamically  
add/remove spacers, I would suggest utilizing #remove() to remove it.  
wxSizerItem is not employed within wxRuby, as it’s of more use  
internally,  
then externally.
