From: Lyle Johnson Date: 2002-12-12T00:59:07+09:00 Subject: Re: FXRuby : Setting Default Height/Width in an FXList Jason Persampieri wrote: > I'm attempting to wipe everything from one area and > replace it with some other widgets. I have two > strategies. > > (1) delete and recreate the parent > newParent = FXVerticalFrame.new(parent.parent, ...) > parent.destroy > parent = newParent > parent.create > > this is sloppy, but I figured it'd work. > Unfortunately, the parent disappears, but the new one > doesn't take it's place (although it DOES exist out > there) Calling FXWindow#destroy destroys the server-side resources (e.g. the X window associated with the parent widget) but it doesn't make the underlying object go away. Another way to look at it is that FXWindow#destroy is the opposite of FXWindow#create. What you want to do is blow away the parent window object altogether, and to do that you want to call FXWindow#removeChild: grandParent = parent.parent grandParent.removeChild(parent) parent = FXVerticalFrame.new(grandParent, ...) > (2) delete all the child widgets of parent > 0.upto(parent.numChildren-1) do |childNum| > parent.childAt(childNum).destroy > end This would also work, if you replace the calls to FXWindow#destroy with a removeChild from the parent, i.e. (numChildren - 1).downto(0) do |childNum| parent.removeChild(parent.childAt(childNum)) end Note that I also changed it from "count up from zero" to "count down from numChildren-1". The reason is that each time you call removeChild(i) you've shifted all of the child widgets with index > i down a slot.