Assaph Mehr
2006-May-19 03:55 UTC
[fxruby-users] Dynamically removing & adding widgets at runtime
Hi all, Am facing a problem where I dynamically remove and add widgets at runtime, but the new widgets are not drawn. Attached is a simple reproduction script. Basically, this app helps me manage a particular set of services on various machines (for easy read, the attached samples just works with file names). When switching machines I remove all entries from the groupbox, and add all entries for the new location. What I can see is that the existing entries are removed, the whole frame is resized to the new number of entries, but no the groupboxes remain blank - the new items are not shown. To reproduce, run the attached script, see the dir listing in the current directory, click "reload" and select a new dir - and see my problem. Am probably missing something obvious. Have tried various things like update, layout etc but can''t seem to make it work. Any help much appreciated, Assaph -------------- next part -------------- A non-text attachment was scrubbed... Name: test.rb Type: application/x-ruby Size: 2382 bytes Desc: not available Url : http://rubyforge.org/pipermail/fxruby-users/attachments/20060519/fdcbebbd/attachment.bin
Assaph Mehr
2006-May-19 06:43 UTC
[fxruby-users] Dynamically removing & adding widgets at runtime
> Am facing a problem where I dynamically remove and add widgets at > runtime, but the new widgets are not drawn. Attached is a simple > reproduction script.Seems like a generic problem with adding widgets. Here is a simpler reproduction: require ''fox14'' include Fox class ControllerWindow < FXMainWindow def initialize(app) super(app, "Test", nil, nil, DECOR_ALL, 500, 300) @reload_btn = FXButton.new(self, "Add") @reload_btn.connect(SEL_COMMAND) do l = FXLabel.new(self, "Aa") self.title = self.numChildren.to_s resize(getDefaultWidth(), getDefaultHeight()) end end end obj_controller_app = FXApp.new obj_controller_window = ControllerWindow.new(obj_controller_app) obj_controller_app.create obj_controller_window.show obj_controller_app.run Using FXRuby 1.4.6. Thanks, Assaph
Tobias Herzke
2006-May-19 06:49 UTC
[fxruby-users] Dynamically removing & adding widgets at runtime
I think you need to call create on the new widgets, like def reload_data @dir = FXDirDialog.getOpenDirectory(self, "Dir", "Select path") build_service_lists [@file_group, @dir_group].each{|grp| grp.children.each{|ch| ch.create} } resize(getDefaultWidth(), getDefaultHeight()) end best regards, Tobias
Assaph Mehr
2006-May-19 10:39 UTC
[fxruby-users] Dynamically removing & adding widgets at runtime
On 5/19/06, Tobias Herzke <fxrbu1 at gi2.herzkes.de> wrote:> I think you need to call create on the new widgets, likePerfect, thanks! Also, self.create seems to work just as well, no need to iterate over the child objects. Cheers, Assaph