- 论坛徽章:
- 0
|
wxRuby是一个开源的ruby界面开发包。它提供wxWidgets这个跨平台的C++界面框架的Ruby支持。wxWidgets是一个成熟的,拥 有众多特性的界面开发包,它使用本地控件来提供Linux、Windows和OS X本地的界面风格。wxRuby的目标是提供动态的Ruby扩展,用与原型开发和普通的界面开发。
wxRuby 开发应用的6个步骤:
require "wx"
include Wx
Create a class that inherits from App
Override on_init()
Create a new instance of your derived App class
Call its main_loop() method
[代码] [Ruby]代码
01 require "wx"
02 include Wx
03
04 # a new class which derives from the Wx::App class
05 class HelloWorld < App
06 # we're defining what the application is going to do when it starts
07 def on_init
08 # it's going to make a frame entitled "Hello World"
09 helloframe = Frame.new(nil, -1, "Hello World")
10 # it's going to put the text "Hello World" in that frame
11 StaticText.new(helloframe,-1,"Hello World")
12 # and then it's going to make the window appear
13 helloframe.show()
14 end
15 end
16 # and this line makes it actually do it!
17 HelloWorld.new.main_loop
[代码] 一个最为简单的Frame窗体
01 require "wx"
02 include Wx
03
04
05 class MinimalApp < App
06 def on_init
07 Frame.new(nil, -1, "The Bare Minimum").show()
08 end
09 end
10
11
12 MinimalApp.new.main_loop |
|