Yuri Leikind wrote:
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.
Hello all, Is there a way in Fox to add widgets after the widget hierarchy has been built and FXApp#run has started ? Say, I have an empty FXScrollWindow, and I want to add FXMatrix to it with lots of its own children, on some event (button click, etc). So far, I have not found a way to see the widgets I've added. -- Best regards, Yuri Leikind...
Hello all,
Is there a way in Fox to add widgets after the widget hierarchy has been built and
FXApp#run has started ?
Say, I have an empty FXScrollWindow, and I want to add FXMatrix to it with
lots of its own children, on some event (button click, etc).
So far, I have not found a way to see the widgets I've added.
--
Best regards,
Yuri Leikind
Yuri Leikind wrote:
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.
On Sat, 24 Jan 2004 00:29:58 +0900
Lyle Johnson <sourceforge.net> wrote:
>
> 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.[/ref]
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.
--
Best regards,
Yuri Leikind
On Jan 23, 2004, at 12:38 PM, Yuri Leikind wrote:
<snip>
The problem is that merely adding an FXScrollWindow to the FXGroupBox
during that second call to build() doesn't mark the layout of the group
box as "dirty". That is to say, FOX doesn't assume that adding the
scroll window changed the size of the parent group box (grbox2), and so
that widget's layout doesn't get recalculated as a result. In this
case, you need to explicitly mark the group box layout as dirty by
calling its recalc() method. Try adding the following line at the end
of build(), after the call to FXScrollWindow#create:
scrollarea.recalc
and see if you get the result you're after.
Hope this helps,
Lyle
On Sat, 24 Jan 2004 13:50:06 +0900
Lyle Johnson <net> wrote:
Oh yes, it does, thank you again.
--
Best regards,
Yuri Leikind
Bookmarks