[fxruby-users] Re: FXRuby and Threads (was: radiobuttons are weird in 1.2.x series)

Bil bil.bas at virgin.net
Thu Jul 22 21:35:58 EDT 2004



*********** REPLY SEPARATOR  ***********

On 22/07/2004 at 14:01 lyle at knology.net wrote:

>On Thu, 22 Jul 2004 14:47:47 +0100, "Bil" <bil.bas at virgin.net> wrote :
>
>> Err, well it does work, though it does not require the background thread
>to run very fast at all. The application is a prototype of a board-game
>engine. The server is a regular threaded Ruby application (no FXRuby at
>all). The client is obviously an FXRuby app.
>
>Wait, are we talking about two different Ruby processes here? I mean, do we
>have a single-threaded client (which is a FXRuby app) running in process A,
>and a multi-threaded server (a non-FXRuby app) running in process B? If so,
>yeah, that should work.
>
>I was talking about a single Ruby application (process) that uses FXRuby
>and
>has multiple threads. For an example, see the groupbox.rb example program
>that comes with FXRuby. There should be a little clock in the lower
>right-hand corner that's being updated by a thread, i.e. threads support is
>"enabled" for that particular program.

I looked at groupbox.rb again...
Changed the radiobuttons in the GroupBox to:
    gp = FXVerticalFrame.new(group3,
      LAYOUT_SIDE_TOP|FRAME_GROOVE|LAYOUT_FILL_X, 0, 0, 0, 0)
    dt = FXDataTarget.new 1
    FXRadioButton.new(gp, "Hilversum &1", dt, FXDataTarget::ID_OPTION+1,
      ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP)
    FXRadioButton.new(gp, "Hilversum &2", dt, FXDataTarget::ID_OPTION+2,
      ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP)
    FXRadioButton.new(gp, "One multi-line\nRadiobox Widget", dt, FXDataTarget::ID_OPTION+3,
      JUSTIFY_LEFT|JUSTIFY_TOP|ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP)
    FXRadioButton.new(gp, "Radio Stad Amsterdam", dt, FXDataTarget::ID_OPTION+4,
      ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP)

I added this to GroupWindow#create()
    app.addChore method(:giveTime)

Added this method to GroupWindow:
  def giveTime(sender, sel, data)
    app.addChore method(:giveTime)
  end

and put this in run()
  application.disableThreads

and...it works entirely fine - clock AND radiobuttons! It also worked using "app.addTimeout 50, method(:giveTime)". Hope that helps you work out why this is working *8-P*

bil







More information about the fxruby-users mailing list