# Debugging sizer usage and gui layout

**URL:** <https://www.ruby-forum.com/t/debugging-sizer-usage-and-gui-layout/174106>\
**Category:** wxRuby\
**Created:** [August 20, 2009, 10:12pm UTC](https://www.ruby-forum.com/t/debugging-sizer-usage-and-gui-layout/174106 "2009-08-20T22:12:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pitosalas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a4c791/32.png) [@pitosalas](https://www.ruby-forum.com/u/pitosalas)\
**Post date:** [August 20, 2009, 10:12pm UTC](https://www.ruby-forum.com/t/debugging-sizer-usage-and-gui-layout/174106/1 "2009-08-20T22:12:47Z")

</div>

In other gui packages I have seen special ‘debug modes’ on panels or  
frames which highlighted the specific placement and size of each window  
and subwindow (as determined by sizers) to help you visualize why things  
aren’t working as expected. Is there such a thing in wxRuby (or Wx in  
general?)

Pito S.

---

<div class="post-metadata">

**Author:** ![pitosalas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a4c791/32.png) [@pitosalas](https://www.ruby-forum.com/u/pitosalas)\
**Post date:** [August 21, 2009, 1:05pm UTC](https://www.ruby-forum.com/t/debugging-sizer-usage-and-gui-layout/174106/2 "2009-08-21T13:05:45Z")

</div>

Hello Pito,

There isn’t one specifically built into wxRuby, however, doing this  
shouldn’t be to hard, simply do the following in a Module, and include  
it  
into your class:

module Wx  
module DebugWindow  
def debug\_on\_size(event)  
@debugSize = event.size  
event.skip  
end

```
def debug_on_paint(event)
  self.paint do |dc|
    dc.set_text_foregound(Wx::RED)
    dc.set_text_background(Wx::GREEN)
    dc.draw_text("Size of Window is:

```

#{@debugSize.width}x#{@debugSize.height}")  
end unless @debugSize.nil?  
event.skip  
end

```
def included(base)
  base.eval("evt_size(:debug_on_size)")
  base.eval("evt_paint(:debug_on_paint)")
end

```

end

class MyWindow \< Wx::Window  
include Wx::DebugWindow

… do your code here …  
end

This is a small sample, and is not garunteed to run exactly as  
advertised,  
and may take some tweaking in order to fix it properly.

---

<div class="post-metadata">

**Author:** ![pitosalas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a4c791/32.png) [@pitosalas](https://www.ruby-forum.com/u/pitosalas)\
**Post date:** [August 28, 2009, 3:41pm UTC](https://www.ruby-forum.com/t/debugging-sizer-usage-and-gui-layout/174106/3 "2009-08-28T15:41:11Z")

</div>

Hi Pito

Pito S. wrote:

> In other gui packages I have seen special ‘debug modes’ on panels or  
> frames which highlighted the specific placement and size of each window  
> and subwindow (as determined by sizers) to help you visualize why things  
> aren’t working as expected. Is there such a thing in wxRuby (or Wx in  
> general?)

Yes -  
[http://thread.gmane.org/gmane.comp.lib.wxwidgets.general/53232/focus=53233](http://thread.gmane.org/gmane.comp.lib.wxwidgets.general/53232/focus=53233)

I haven’t ever tried this myself. Also note that the distributed wxRuby  
builds are based on RELEASE rather than DEBUG builds of Wx - so unless  
you compile yourself this won’t be available.

It’s not a solution for everything, but trying things out in a GUI  
designer can often help with the trickier bits of nesting, even if you  
don’t use XRC for the final code.

cheers  
a
