Ruby-GUI之FxRuby
段哲圣
2023-12-01
一. 概论
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