Current wxRuby status

Hi, All

Do you know I’m working on wxRuby at http://sourceforge.jp/projects/wxruby ?
You can download the beta version 0.01.
Sorry for no documents,many missing classes and methods.

Tested on

Windows XP
wxMSW 2.4.0
ruby 1.8.0 preview2
Visual C++ 6.0

RedHat Linux 8.0
wxGTK 2.4.0
ruby 1.8.0 preview2
gcc 3.2

Here is sample code.

=begin CODE

require 'wx'
include Wx

Minimal_Quit = 1
Minimal_About = WxID_ABOUT

def labeledEntry(parent,sizer,label,default)
  sizer.Add(WxStaticText.new(parent,-1,label.to_s,

WxDefaultPosition,WxDefaultSize,WxALIGN_RIGHT),1,WxALIGN_CENTER_VERTICAL)
sizer.Add(r=WxTextCtrl.new(parent,-1,default.to_s,
WxDefaultPosition,WxDefaultSize,WxALIGN_LEFT),1,WxALIGN_CENTER_VERTICAL)
return r
end

class MyFrame < WxFrame
  def initialize(title,pos,size,style=WxDEFAULT_FRAME_STYLE)
    super(nil,-1,title,pos,size,style)

    if WxRUBY_PLATFORM == "WXMSW"
      SetIcon(WxIcon.new("mondrian.ico",WxBITMAP_TYPE_ICO))
    else
      SetIcon(WxIcon.new("mondrian.xpm",WxBITMAP_TYPE_XPM))
    end

    menuFile = WxMenu.new
    helpMenu = WxMenu.new
    helpMenu.Append(Minimal_About, "&About...\tF1", "Show about dialog")
    menuFile.Append(Minimal_Quit, "E&xit\tAlt-X", "Quit this program")
    menuBar = WxMenuBar.new
    menuBar.Append(menuFile, "&File")
    menuBar.Append(helpMenu, "&Help")
    SetMenuBar(menuBar)

    CreateStatusBar(2)
    SetStatusText("Welcome to wxRuby!")

    EVT_MENU(self, Minimal_Quit,  "OnQuit")
    EVT_MENU(self, Minimal_About,  "OnAbout")
  end

  def OnQuit(event)
    Close(TRUE)
  end

  def OnAbout(event)
    msg =  sprintf("This is the About dialog of the minimal sample.\n" \
         "Welcome to %s", WxVERSION_STRING)

    WxMessageBox(msg, "About Minimal", WxOK | WxICON_INFORMATION, self)
  end
end

class WxRbApp < WxApp
  def OnInit
    frame = MyFrame.new("Minimal wxRuby App",WxPoint.new(50, 50),

WxSize.new(450, 340))
frame.Show(TRUE)
end
end

a = WxRbApp.new
a.MainLoop()

=end CODE

I have some issues about current version.

  1. Library name should be renamed?
    require ‘wx’ ==> require ‘wxRuby’ or else.

  2. Constant name should be renamed?
    WxOK ==> OK or
    Wx::WxOK ==> Wx::OK

  3. Event handler method name convention
    EVT_MENU(self,Minimal_Quit,“OnQuit”) ==>
    EVT_MENU(self,Minimal_Quit,:OnQuit) or else.

  4. Ruby thread support routine
    I used OnIdle event handler like this.

    void wxRbApp::OnIdle(wxIdleEvent& event)
    {
    struct timeval wait;

     wait.tv_sec  = 0;
     wait.tv_usec = 100000; /* 100ms */
    
     CHECK_INTS;
     if (!rb_thread_critical) rb_thread_wait_for(wait);
    
     wxApp::OnIdle(event);
    

    }

    Is it the best way or is there some other way?

  5. building C++ extention library without SWIG or other automated tools.
    It needs more time and more coding, but the source code is easy to
    understand.

What do you think about the above issues?

I wish someone inspect my source code and correct bugs and problems.

Regards,

Park Heesob

Hi, All

Do you know I’m working on wxRuby at http://sourceforge.jp/projects/wxruby ?
You can download the beta version 0.01.
Sorry for no documents,many missing classes and methods.

Thanks! I think this is the toolkit I’ve been waiting for, but I
thought it was vaporware, because the sourceforge.net (not .jp) site is
empty. You might want to set that to redirect to the real site.

I have some issues about current version.

  1. Library name should be renamed?
    require ‘wx’ ==> require ‘wxRuby’ or else.

Well, other toolkits use names like “gtk2”, “gnome2”, “fox”, so “wx” or
“wxwindows” might be the most consistent.

  1. Event handler method name convention
    EVT_MENU(self,Minimal_Quit,“OnQuit”) ==>
    EVT_MENU(self,Minimal_Quit,:OnQuit) or else.

I personally like strings. I don’t know why.

  1. Ruby thread support routine
    I used OnIdle event handler like this.

    void wxRbApp::OnIdle(wxIdleEvent& event)
    {
    struct timeval wait;

     wait.tv_sec  = 0;
     wait.tv_usec = 100000; /* 100ms */
    
     CHECK_INTS;
     if (!rb_thread_critical) rb_thread_wait_for(wait);
    
     wxApp::OnIdle(event);
    

    }

    Is it the best way or is there some other way?

You might want to check how Ruby-Gnome2 does it; it’s probably similar.

BTW, how do I compile this in Linux?

···

On Thu, 2003-05-15 at 00:11, Park Heesob wrote:


Tom Felker

65 != 97, 0x41 != 0x61, 0101 != 0141,
similarly, ‘A’ != ‘a’

No I didn’t. Great news and keep up the good work!

Concerning the design of the interface I think you are well adviced to
check how Lyle do things in FXRuby; in my opinion its a very
nice interface. Similarity of different GUI extensions also makes its
simpler to then do an extension à la anygui where the actual GUI used is
just a plugin.

If I were doing a Ruby gui extension I’d keep a list of my design choices
and how/why they deviate from FXRuby’s… :wink:

Regards,

Robert Feldt

···

On Thu, 15 May 2003, Park Heesob wrote:

Hi, All

Do you know I’m working on wxRuby at http://sourceforge.jp/projects/wxruby ?

Concerning the design of the interface I think you are well adviced to
check how Lyle do things in FXRuby; in my opinion its a very
nice interface. Similarity of different GUI extensions also makes its
simpler to then do an extension à la anygui where the actual GUI used is
just a plugin.

While that’s certainly true, one might argue that it’s also
advantageous to emulate the Python wxWindows style. Anyone already
familiar with the Python way can then easily port GUI code written in
Python into Ruby.

Good point although I doubt there is (or will be) a large amount of
porting-Python-to-Ruby going on. I’d rather have a Ruby-natural
wxRuby than a so-so-Ruby-but-close-to-wxPython wxRuby… :wink:

Maybe you can list the “main ideas” in the wxPython style for folks like
me (and Park?) that don’t know them? Just a short overview?

Regards,

/Robert

···

On Tue, 20 May 2003, Arthur wrote:

Concerning the design of the interface I think you are well adviced to
check how Lyle do things in FXRuby; in my opinion its a very
nice interface. Similarity of different GUI extensions also makes its
simpler to then do an extension à la anygui where the actual GUI used is
just a plugin.

While that’s certainly true, one might argue that it’s also
advantageous to emulate the Python wxWindows style. Anyone already
familiar with the Python way can then easily port GUI code written in
Python into Ruby.

Concerning the design of the interface I think you are well adviced to
check how Lyle do things in FXRuby; in my opinion its a very
nice interface. Similarity of different GUI extensions also makes its
simpler to then do an extension à la anygui where the actual GUI used is
just a plugin.

While that’s certainly true, one might argue that it’s also
advantageous to emulate the Python wxWindows style. Anyone already
familiar with the Python way can then easily port GUI code written in
Python into Ruby.

That is a good point, and I do feel it’s worthwhile
to toss a bone or two to the Pythoners… (we have
tossed so many to the Perlers).

Perhaps the two are not mutually exclusive. Perhaps
the Python style could be a subset of the Ruby-wxWindows
API.

But this is just idle speculation, as I know neither
Python nor wxWindows.

Hal

···

----- Original Message -----
From: “Arthur” arthur8@boardermail.com
Newsgroups: comp.lang.ruby
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Tuesday, May 20, 2003 5:52 AM
Subject: Re: Current wxRuby status