Re: [Fxruby-users] Creating new frames
Status: Inactive
Brought to you by:
lyle
|
From: meinrad r. <mei...@gm...> - 2003-10-08 15:01:13
|
Phil Sharp wrote:
> I want to create different entry fields depending upon which button is
> selected. I would like to do this by calling a function (see example
> below, pressing <Add> should create one label and one text entry box).
>
> This does not work and I thought it was because it was created but hidden,
> however adding a .show had no effect.
you have to call the create method on all widgets that have been
instanciated later than your call to application.create.
also you have to call the reaclc method on the containing widget, in
order to tell it, that it should make its layout new.
> If someone could enlighten me I
> would appreciate it.
>
here is your working code:
#!/usr/bin/env ruby
require 'fox'
include Fox
class Test < FXMainWindow
def initialize(app)
super(app, "Test", nil, nil, DECOR_ALL, 0, 0, 640, 480, 0, 0)
body =
FXVerticalFrame.new(self,LAYOUT_SIDE_TOP|FRAME_RAISED|LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH
)
topbuttons=FXHorizontalFrame.new(body,LAYOUT_SIDE_TOP|FRAME_RAISED|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH,
0, 0, 0, 0,20, 20, 20, 20)
FXButton.new(topbuttons, "Add").connect(SEL_COMMAND) {add(body) }
FXButton.new(topbuttons, "&Quit", nil, app, FXApp::ID_QUIT)
end
def add(body)
lbl=FXLabel.new(body,"text 1")
tf=FXTextField.new(body,numcolumns=20)
lbl.create
tf.create
body.recalc
end
def create
super
show(PLACEMENT_SCREEN)
end
end
application = FXApp.new("Test", "FoxTest")
Test.new(application)
application.create
application.run
regards,
-- henon
--------------
% cat "food in cans"
cat: can't open food in cans
|