[wxruby-users] wxRuby dialog separate from main Ruby script execution

Alex Fenton alex at pressure.to
Thu Jan 15 08:17:06 EST 2009


David Muir wrote:
> The reason I don't have a single point of entry, and spawned a thread 
> for the UI, is because I want this as a bolt on to existing scripts.
>
> Such that existing scripts can be run with displaying a log when the 
> end-user runs it or not displaying a UI when an automated process is 
> running the script(s).

I don't know Log4r but you can define custom Loggers etc. Define one 
that call Wx::log_message, Wx::log_warn etc in response to the Log4r 
calls in your core file. Your UI shell is going to look something like 
the structure below:

hth
alex
__

require 'wx'

### Custom outputter /logger here

# What to run
scripts = [ 'foo.rb' ]

Wx::App.run do
  Wx::log_message('Starting')
  t = Thread.new do
    scripts.each do | script |
      Wx::log_message("Running #{script}")
      load script
    end
  end

  Wx::Timer.every(25) { Thread.pass }
  true
end





More information about the wxruby-users mailing list