Friday, November 12, 2010

wxRuby Programming (1) - a simple window

1. My first program with wxRuby is just to display a simple window.
#!/usr/bin/env ruby
# window02.rb
#
require 'rubygems'
require 'wx'
 
class AppFrame < Wx::Frame
 
 def initialize
  super(nil)
  window_settings
 end
 
 def window_settings
  set_title 'Simple Window'
  set_size 400,300
 end
   
end
 
class MyApp < Wx::App
 def on_init
  @frame = AppFrame.new
  @frame.show
 end
end
 
app = MyApp.new
app.main_loop

2. This is the result.
3. References http://ruby.about.com/od/gui/qt/wxrubyworld.htm

No comments:

Post a Comment