How to refresh a panel?

Hello again

This time i have a problem with this code

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.

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
when the event is called
###end initialize

###event functions##
def cState(menu)##the function called from the event
#@panel.destroy ## Error: undefined method `destroy’ for
nil:NilClass (NoMethodError)
@panel=Test.new(self)##a WX::Panel class.
end
##the other function is similar to this one
###end event functions

if i’m doing the wrong way, please tellme, and if possible, post a link
to an example, tutorial or explanation. I’d be very thankful

Ramo

Omar H. 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