- 論壇徽章:
- 0
|
wxRuby是一個(gè)開源的ruby界面開發(fā)包。它提供wxWidgets這個(gè)跨平臺(tái)的C++界面框架的Ruby支持。wxWidgets是一個(gè)成熟的,擁 有眾多特性的界面開發(fā)包,它使用本地控件來提供Linux、Windows和OS X本地的界面風(fēng)格。wxRuby的目標(biāo)是提供動(dòng)態(tài)的Ruby擴(kuò)展,用與原型開發(fā)和普通的界面開發(fā)。
wxRuby 開發(fā)應(yīng)用的6個(gè)步驟:
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
[代碼] 一個(gè)最為簡(jiǎn)單的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 |
|