Hello all,
Is anybody working on wxWindows for Ruby?
I know the project to wrap wxwindows for ruby called
wxruby(http://sourceforge.net/projects/wxruby/).
But I can’t see any change.
So I made my own version of wxruby adapted from wxPython only for
MS-Windows.
It just works but if fails to exit gracefully.
I wish someone maintain wxruby project for other platforms and document.
Download at http://www.physics.pe.ly/wxruby.zip
Requirement:
Visual C++ 6.0
wxWindows 1.3.2
Install:
Unzip wxruby.zip
nmake -f makefile.swig
nmake
ruby test.rb
Test code following
···
===========================================================
require 'wx’
include Wx
MENU_FILE_OPEN,MENU_FILE_SAVE,MENU_FILE_QUIT,MENU_INFO_ABOUT = 1…4
class TextFrame < WxFrame
def initialize(title,xpos,ypos,width,height)
super(nil, -1, title, WxPoint.new(xpos, ypos), WxSize.new(width, height))
@m_pTextCtrl = WxTextCtrl.new(self, -1, “Type some text…”,
Wx::wxDefaultPosition, Wx::wxDefaultSize, Wx::WxTE_MULTILINE)
@m_pMenuBar = WxMenuBar.new
@m_pFileMenu = WxMenu.new
@m_pFileMenu.Append(MENU_FILE_OPEN, “&Open”, “Opens an existing file”)
@m_pFileMenu.Append(MENU_FILE_SAVE, “&Save”, “Save the content”)
@m_pFileMenu.AppendSeparator();
@m_pFileMenu.Append(MENU_FILE_QUIT, “&Quit”, “Quit the application”)
@m_pMenuBar.Append(@m_pFileMenu, “&File”)
@m_pInfoMenu = WxMenu.new
@m_pInfoMenu.Append(MENU_INFO_ABOUT, “&About”, “Shows information about the
application”)
@m_pMenuBar.Append(@m_pInfoMenu, “&Info”)
SetMenuBar(@m_pMenuBar)
CreateStatusBar(3)
SetStatusText(“Ready”, 0)
end
def OnMenuFileOpen
puts "OnMenuFileOpen"
end
def OnMenuFileSave
puts "OnMenuFileSave"
end
def OnMenuFileQuit
Close(0)
end
def OnMenuInfoAbout
puts "OnMenuInfoAbout"
end
end
class WxApp < WxRbApp
def initialize
super
__wxStart(self)
end
def OnInit()
@frame = TextFrame.new(“Simple Text Editor”, 200, 200, 500, 500)
EVT_MENU(@frame, MENU_FILE_OPEN, “OnMenuFileOpen”)
EVT_MENU(@frame, MENU_FILE_SAVE, “OnMenuFileSave”)
EVT_MENU(@frame, MENU_FILE_QUIT, “OnMenuFileQuit”)
EVT_MENU(@frame, MENU_INFO_ABOUT, “OnMenuInfoAbout”)
@frame.Show()
SetTopWindow(@frame)
end
end
a = WxApp.new
a.MainLoop()
exit!
- Park Heesob