wxRuby2的安装与Demo程序

用gem安装wxruby2

c:>gem install wxruby2-preview

在文件前面增加下列代码

begin
   require "wx"
rescue LoadError => no_wx_err
   begin
     require "rubygems"
     require "wx"
   rescue LoadError
     raise no_wx_err
   end
end

测试:

class TroutApp < Wx::App
   def on_init
     frame = Wx::Frame.new(nil, -1, "Tiny wxRuby Application")
     panel = Wx::StaticText.new(frame, -1, "You are a trout!",
           Wx::Point.new(-1,1), Wx::DEFAULT_SIZE,
           Wx::ALIGN_CENTER)
     frame.show
   end
end

TroutApp.new.main_loop

update:

FOX界面库

require "fox16"
include Foxapplication = FXApp.new("Hello", "FoxTest")

application.init(ARGV)
main = FXMainWindow.new(application, "Hello", nil, nil, DECOR_ALL)
FXButton.new(main, "&Hello, World!", nil, application, FXApp::ID_QUIT)
application.create()
main.show(PLACEMENT_SCREEN)
application.run()
Scroll to top