Hi, I''m trying to get to grips with a Ruby GUI and have plunked for Fox and/or FoxGUIb. I''m having problems at the moment trying to do something simple which I can''t find in the samples or tutorials how to do. Basically, in my main window, its composed of 2 vertical frames. There is a menu at the top for all the options. All Im trying to do is display text inputs fields in the left vertical frame.This is for user input, to run specific apps. What text fields shown are dependant on the menu option chosen. The right frame is a response screen.Below is some snippets:- ..... My left vertical frame for data input..... @group1 = FXGroupBox.new(contents, "Information", :opts => GROUPBOX_TITLE_LEFT|FRAME_RIDGE|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT, :width => 200, :height => 400) ...... My menu option....... mymenu = FXMenuPane.new(self) FXMenuTitle.new(menubar, "&Target", nil, mymenu, LAYOUT_LEFT) details=FXMenuCommand.new(mymenu, "&Details").connect(SEL_COMMAND) do FXTextField.new(@group1, 10, :opts => FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X) end What I thought should have happend in the above snippet was that on selecting the ''mymenu'' option, a new text field would be entered into the vertical frame ''@group1''. However this doesnt happen. Nothing happens. Ideally, I''d like the command on selecting the menu option to go to a function that changes the look of the vertical frame i.e, showing different text fields dependant on the menu chosen. Im sure its a syntex issue. Can you point me to an example on how this can be done? Thanks, -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/fxruby-users/attachments/20070822/ce8e4e7d/attachment.html
On Aug 22, 2007, at 7:01 AM, David Kirkpatrick wrote:> I''m trying to get to grips with a Ruby GUI and have plunked for Fox > and/or FoxGUIb. I''m having problems at the moment trying to do > something simple which I can''t find in the samples or tutorials how > to do...<snip>> ...... My menu option....... > > mymenu = FXMenuPane.new(self) > FXMenuTitle.new(menubar, "&Target", nil, mymenu, LAYOUT_LEFT) > details=FXMenuCommand.new(mymenu, "&Details").connect > (SEL_COMMAND) do > FXTextField.new(@group1, 10, :opts => FRAME_SUNKEN| > FRAME_THICK|LAYOUT_FILL_X) > end > > What I thought should have happend in the above snippet was that on > selecting the ''mymenu'' option, a new text field would be entered > into the vertical frame ''@group1''. However this doesnt happen. > Nothing happens.You need to add a call to create() for the dynamically created text fields, e.g. details = FXMenuCommand.new(...) details.connect(SEL_COMMAND) do textfield = FXTextField.new(@group1, ...) textfield.create @group1.recalc end The create() creates the server-side resources (windows) for the newly constructed widgets, and calling recalc() on the group box marks its layout as dirty.> Ideally, I''d like the command on selecting the menu option to go to > a function that changes the look of the vertical frame i.e, showing > different text fields dependant on the menu chosen. Im sure its a > syntex issue. > > Can you point me to an example on how this can be done?I''m not sure I follow you. You can just call a function from inside the connect() block, e.g. details.connect(SEL_COMMAND) { update_groupbox_contents } and then, somewhere else: def update_groupbox_contents textfield = FXTextField.new(@group1, ...) textfield.create @group1.recalc end Hope this helps, Lyle
On Aug 22, 2007, at 11:13 AM, David Kirkpatrick wrote:> That did the trick. thanks a lot. Basically u need to ''create'' > anything in a frame, and do a ''recalc'' on the frame each time the > output changes.Yes.> Is there anywhere where that sort of info is documented? I trawled > for a couple of days over the tutorials etc. with no obvious > solution. My app is going to be an ongoing thing, so if there''s any > good material I missed can u point me in the right direction. Any > reference to those sorts of functions would be good.Hypothetically speaking, someone might be writing a book about FXRuby that should be published later this year. But that doesn''t help you in the short term. The best resources, for now, are the documentation at the FOX web site (http://www.fox-toolkit.org/) and the FXRuby web site (http://www.fxruby.org/). There''s also some coverage of FXRuby in Hal Fulton''s book The Ruby Way (2nd ed.), which is a good book to have in general if you''re doing Ruby work. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/fxruby-users/attachments/20070822/9812170d/attachment-0001.html
> > Hypothetically speaking, someone might be writing a book about FXRuby > that should be published later this year.The real question, hypothetically speaking that is, is whether there''ll be a release party... And, hypothetically speaking, will there be beer... Sander> > > > > ------------------------------------------------------------------------ > > _______________________________________________ > fxruby-users mailing list > fxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/fxruby-users
I''ll drink to that !! Till then I''ll battle on.... ta ----- Original Message ---- From: Sander Jansen <sander at knology.net> To: fxruby-users at rubyforge.org Sent: Friday, 24 August, 2007 4:37:06 AM Subject: Re: [fxruby-users] Ruby Fox newbie query> > Hypothetically speaking, someone might be writing a book about FXRuby > that should be published later this year.The real question, hypothetically speaking that is, is whether there''ll be a release party... And, hypothetically speaking, will there be beer... Sander> > > > > ------------------------------------------------------------------------ > > _______________________________________________ > fxruby-users mailing list > fxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/fxruby-users_______________________________________________ fxruby-users mailing list fxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/fxruby-users -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/fxruby-users/attachments/20070824/458b4cb8/attachment.html