Forum: wxRuby How to refresh a panel?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8169bd2772aa4c151c8688dd1b08348e?d=identicon&s=25 Omar Hernandez (ramo)
on 2008-11-14 01:22
Attachment: testPrincipal.zip (1 KB)
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
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2008-11-14 01:58
(Received via mailing list)
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
This topic is locked and can not be replied to.