免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2688 | 回复: 2
打印 上一主题 下一主题

Hello world 之 wxRuby 版 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-01-14 13:11 |只看该作者 |倒序浏览
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

论坛徽章:
0
2 [报告]
发表于 2011-01-14 16:08 |只看该作者
一下子多了这么多帖子?

论坛徽章:
0
3 [报告]
发表于 2011-01-16 10:33 |只看该作者
FXRuby也非常好!!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP