[fxruby-users] dynamically changing dialogs

Forrest Chang fkchang2000 at yahoo.com
Fri Jan 6 17:37:52 EST 2006


Hi All:

  I want to dynamically change a subclass of
FXDialogBox after it'd been displayed.  I did some
googling and found that widget.create solves the
problem on FXMainWindow, but does not seem to do the
same with an FXDialogBox.    I have a code sample that
creats a main window with a button to display a
simplified dialog which adds 2 "entries" to itself in
initialize() and gives a button to add additional
entries.  The 2 buttons added in intialize work, but I
can't see them added later.

  Any ideas? TIA

Forrest

--------------------------------
#!/usr/bin/env ruby
require 'rubygems'
require_gem 'fxruby'
require 'fox12'
include Fox

class TestGui < FXDialogBox

  def add_entry( create)
    but = FXButton.new( @test_entries_frame, "foo")
    but.create if create        # don't create when
called in initialize
  end

  def initialize(owner)
     super(owner, "Test", DECOR_ALL,
       0, 0, 600, 400)

    vframe = FXVerticalFrame.new(
self,LAYOUT_FILL_X|LAYOUT_FILL_Y)

    FXButton.new( vframe, "Add
Entry").connect(SEL_COMMAND) {
      # add entry with create
      add_entry( true)
    }

    @test_entries_frame = FXVerticalFrame.new( vframe,
LAYOUT_FILL_X|LAYOUT_FILL_Y)
    # add entry without create
    add_entry( nil)
    add_entry( nil)
    show PLACEMENT_CURSOR

  end                           # initialize
  
end                             # TestGui


if $0 == __FILE__
  app = FXApp.new( 'dynamic demo')
  mw = FXMainWindow.new( app, "dynamic demo", nil,
nil, DECOR_ALL)

  FXButton.new( mw, "show selector").connect(
SEL_COMMAND) {
    dg = TestGui.new( app)
    dg.execute
  }

  mw.show
  app.create
  app.run
end



More information about the fxruby-users mailing list