« Return to Thread: updata of a value from outside

updata of a value from outside

by jabowen :: Rate this Message:

Reply to Author | View in Thread

I have a button in the test gui that runs a random number generator class outside of the gui.  How do I get the field to update inside the gui?  It creates the number but and puts it but does not update the field.  

require 'fox16'
include Fox
class GenNum
        def current_addr
                $current_addr = rand(0)
        end
end
class TestRun < FXMainWindow
        def initialize(app)
                super(app, "Test Run", :width => 400, :height => 100)
                        @rand_num = GenNum.new
                        p = FXVerticalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_CENTER_Y)
                        $intTarget = FXDataTarget.new($current_addr.to_s)

                        FXTextField.new(p, 20, $intTarget, FXDataTarget::ID_VALUE,
                                LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_ROW)
                       
                        activate_button = FXButton.new(p, "test_run",
                                :opts => BUTTON_NORMAL|LAYOUT_CENTER_X)
                        activate_button.connect(SEL_COMMAND) do |sender, sel, data|
                                @rand_num.current_addr
                                p $current_addr
                        end
                end
        def create
                super
                show(PLACEMENT_SCREEN)
        end
end
if __FILE__ == $0
  FXApp.new do |app|
    TestRun.new(app)
    app.create
    app.run
  end
end

 « Return to Thread: updata of a value from outside