See this question from the FOX FAQ list:
http://www.fox-toolkit.org/faq.html#CREATELATER
If you add widgets after the program's started, you'll need to call
create() on them after adding them.
Yes, it does work. In some cases. But in other cases it doesn't. Please take a look at the example:
require "fox"
class App < Fox::FXApp
include Fox
def initialize
super("app")
window = FXMainWindow.new(self,"app", nil, nil, 0, 0, 500, 300)
contents = FXVerticalFrame.new(window, LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y)
grbox1 = FXGroupBox.new(contents, "Options", GROUPBOX_TITLE_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y)
build(grbox1, false)
grbox2 = FXGroupBox.new(contents, "Options", GROUPBOX_TITLE_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y)
#build(grbox2, false)
FXButton.new(contents, "Click me").connect(SEL_COMMAND) do
build(grbox2, true)
end
create
window.show
run
end
def build(parent, creat)
scrollarea = FXScrollWindow.new(parent, VSCROLLER_ALWAYS|LAYOUT_FILL_X|LAYOUT_FILL_Y)
scrollable = FXMatrix.new(scrollarea, 2, MATRIX_BY_COLUMNS|LAYOUT_FILL_X, DEFAULT_SPACING,
DEFAULT_SPACING, DEFAULT_SPACING, DEFAULT_SPACING, 30, 30)
1.upto(10) do
FXLabel.new(scrollable, "some name", nil, LABEL_NORMAL)
FXCheckButton.new(scrollable, "yes", nil, 0, CHECKBUTTON_NORMAL|LAYOUT_SIDE_LEFT)
end
scrollarea.create if creat
end
end
App.new
We have 2 FXScrollWindow instances here, one of which is built before run , another - after.
So that another FXScrollWindow is never seen. I don't see why.