[wxruby-users] How to refresh a panel?

Alex Fenton alex at pressure.to
Thu Nov 13 19:56:37 EST 2008


Omar Hernandez wrote:
> Well, what i'm trying to do is, through a menu, to change panels.
> The problem is that i can't find a way to change the panel, or refresh
> or delete, or whatever should be done.
>   

First off, have a look at whether a Wx::Notebook might suit your 
requirements. It's intended for combining different panels. It has 
methods for switching easily between pages.

If you want to swap panels, you probably just need to destroy the old 
panel and add in the new (see below)

I'm more used to doing this within a sizer-based layout, when it goes 
something like:

new_window = MyWindow.new(old_window.parent, ...)
old_window.containing_sizer.replace(old_window, new_window)
old_window.destroy

This keeps the layout consistent

> i've attached the the zip file with the runable code
>
> the code is:
> ##on 'def initialize' of a Wx::Frame class
> #@Panel=Panel.new(self)##If i initialize @panel here, it doesn't refresh
>   

Well one problem you have is that you call it @Panel here (with a 
capital "P") and @panel later.

alex


More information about the wxruby-users mailing list