一. 概论
Ruby图形化编程最常用的包有:fxruby,TK和gtk+。 fxruby是基于FOX Toolkit的ruby接口,因此编程风格比较接近c的编程。
二.编程步骤
1. 首先要引入fxruby库:
require 'fox16'
include Fox
2. 编写主窗口类,继承于 FXMainWindow
class TestWindow < FXMainWindow
[i] # Call the base class initializer first[/i]
def initializer(app,title)
#Tooltop
tooltip = FXToolTip.new(getApp())
# control
control = FXVerticalFrame.new(self,LAYOUT_SIDE_TOP|FRAME_NONE|LAYOUT_FILL_X|LAYOUT_FILL_Y)
headerFrame = FXVerticalFrame.new (control,FRAME_SUNKEN|FRAME_THICK,:width =>500,height =>500)
end
3. 运行
theApp = FXApp.new("test")
win = TestWindow.new(theApp,"Test")
win.show(PLACEMENT_SCREEN)
theApp.create
theApp.run
Ruby图形化编程最常用的包有:fxruby,TK和gtk+。 fxruby是基于FOX Toolkit的ruby接口,因此编程风格比较接近c的编程。
二.编程步骤
1. 首先要引入fxruby库:
require 'fox16'
include Fox
2. 编写主窗口类,继承于 FXMainWindow
class TestWindow < FXMainWindow
[i] # Call the base class initializer first[/i]
def initializer(app,title)
#Tooltop
tooltip = FXToolTip.new(getApp())
# control
control = FXVerticalFrame.new(self,LAYOUT_SIDE_TOP|FRAME_NONE|LAYOUT_FILL_X|LAYOUT_FILL_Y)
headerFrame = FXVerticalFrame.new (control,FRAME_SUNKEN|FRAME_THICK,:width =>500,height =>500)
end
3. 运行
theApp = FXApp.new("test")
win = TestWindow.new(theApp,"Test")
win.show(PLACEMENT_SCREEN)
theApp.create
theApp.run
本文介绍使用 Ruby 的 fxruby 库进行图形用户界面 (GUI) 开发的基础知识。主要内容包括如何引入 fxruby 库、创建继承自 FXMainWindow 的主窗口类,并展示了基本的编程步骤来构建和展示一个简单的 GUI 应用程序。
17

被折叠的 条评论
为什么被折叠?



