Make frame dynamically size to contents?

What magic and/or code should I use to cause a frame to adjust to fit
the contents? When I change label text, for example… The docs led me
to believe this is done automatically but that doesn’t seem to be the
case… Surely I’ve missed something. :slight_smile:

I’m using sizers for the layout and loading from an xrc, BTW…

Thanks!
Tim

Tim F. wrote:

What magic and/or code should I use to cause a frame to adjust to fit
the contents? When I change label text, for example… The docs led me
to believe this is done automatically but that doesn’t seem to be the
case… Surely I’ve missed something. :slight_smile:
Try Window#set_sizer_and_fit(a_sizer) or Sizer#fit(a_window)

http://wxruby.rubyforge.org/doc/window.html#Window_setsizerandfit
http://wxruby.rubyforge.org/doc/sizer.html#Sizer_fit

hth
alex

Alex F. wrote:

Tim F. wrote:

What magic and/or code should I use to cause a frame to adjust to fit
the contents? When I change label text, for example… The docs led me
to believe this is done automatically but that doesn’t seem to be the
case… Surely I’ve missed something. :slight_smile:
Try Window#set_sizer_and_fit(a_sizer) or Sizer#fit(a_window)

http://wxruby.rubyforge.org/doc/window.html#Window_setsizerandfit
http://wxruby.rubyforge.org/doc/sizer.html#Sizer_fit

hth
alex

Thanks Alex …

One odd thing I notice is that the sizer seems to squash everything
really close together. I added small spacers (2-4 pixels) between
controls to try and pad things out a bit but they seem to be ignored…
I also tried increasing the border sizes on the controls themselves
without success. Any idea what I’m not doing correctly?

Cheers,
Tim

Tim F. wrote:

One odd thing I notice is that the sizer seems to squash everything
really close together. I added small spacers (2-4 pixels) between
controls to try and pad things out a bit but they seem to be ignored…

Borders are definitely the way to go in most cases, not spacers. Are you
using XRC or pure ruby? If using pure ruby, check that you have included
Wx::ALL or Wx::LEFT or Wx::TOP in the third argument to Sizer#add, to
indicate which side of the control you wish to add a border to.

See bigdemo/wxSizer.rbw for a demonstration of some of the options.

If using XRC, check that you have ticked the box to specify which side
you want to add a border to. In DialogBlocks, it usually sets a default
border of 5 on each side.

alex

Alex F. wrote:

Borders are definitely the way to go in most cases, not spacers. Are you
using XRC or pure ruby? If using pure ruby, check that you have included
Wx::ALL or Wx::LEFT or Wx::TOP in the third argument to Sizer#add, to
indicate which side of the control you wish to add a border to.

See bigdemo/wxSizer.rbw for a demonstration of some of the options.

If using XRC, check that you have ticked the box to specify which side
you want to add a border to. In DialogBlocks, it usually sets a default
border of 5 on each side.

alex

Turns out I was fine … I was just requiring the old version of the
frame I did in code rather than the code that loaded XRC I was editing
:-p

Thanks for the help in any case…

Cheers,
Tim