Pages: [1]
  Print  
Author Topic: Writing a Searchable Dictionary with Ruby and wxWidgets  (Read 5703 times)
Scratch Projects
Administrator
novice coder
*****

Karma: +0/-0
Posts: 56


View Profile
« on: May 29, 2006, 09:10:57 PM »

For today's Ruby lesson, we will explore the creation of a simple GUI, and then create an interface allowing us to search a user-created dictionary.

Read the full article at: http://www.scratchprojects.com/2006/05/writing_a_searchable_dictionary_p01.php
Logged
Nathan
n00b
*

Karma: +0/-0
Posts: 27


View Profile
« Reply #1 on: June 01, 2006, 01:37:48 PM »

The usual corrections and mea culpas:

* The first line should read an RSS reader, not just RSS reader
* The second page, third paragraph talks about VBScript. I have no idea how that got in there (pretty sure it wasn't in the document I submitted), but it can be safely ignored.

Hm, only two this time. Obviously I still need to beat my proofreading armadillo for not noticing that I missed a word in the very first sentence of the article.
Logged
Kevin
Administrator
31337
*****

Karma: +1/-0
Posts: 137


View Profile WWW
« Reply #2 on: June 01, 2006, 01:53:48 PM »

The RSS part is fixed. Sorry about the VBScript thing. I used an old article for the template and must have missed removing a line. Thanks Nathan.

Congratulations on all three of your articles being in the most popular section.
Logged

Nathan
n00b
*

Karma: +0/-0
Posts: 27


View Profile
« Reply #3 on: June 02, 2006, 01:33:20 PM »

Thanks.

Extra tidbit for those writing Ruby GUIs:
The standard way to run Ruby programs is by invoking them using the command-line interpreter (like 'ruby myprog.rb'). However, if you invoke them using the program 'rubyw' instead, there is no console instance. Type 'rubyw myprog.rb' and it will return immediately, displaying your GUI in a new process. And if you use that line in a batch file, you don't have the unsightly console window hanging around if you don't need it :)
Logged
Nathan
n00b
*

Karma: +0/-0
Posts: 27


View Profile
« Reply #4 on: August 31, 2007, 04:07:29 PM »

I received an e-mail today about this article that alerted me to some changes to wxRuby since I wrote this article (over a year ago! How time flies).

The most breaking change is that wxRuby, for reasons known but to God, changed the header name from 'wxruby' to 'wx'. Thus, the code should now read
require 'wx'

The sample code distributed with the latest wxRuby package is a good place to start. I noticed that they do some fairly fancy stuff with RubyGems:
Code:
begin
  require 'wx'
rescue LoadError => no_wx_err
  begin
    require 'rubygems'
    require 'wx'
  rescue LoadError
    raise no_wx_err
  end
end
include Wx

That code will automatically install the wxRuby library if it's not installed. To install wxRuby manually, you can just type
gem install wxruby

Of course, both of these methods assume that RubyGems is installed (if not, well, why not?).

I also noticed that the close button on the dialog no longer seems to work! I don't know why this is, and I haven't really had the time to find out, but it means you need to ctrl+c it if you want to close the window. Doh.

It's nice to see ruby libraries progressing along, though sometimes you have to wonder if they couldn't have just aliased 'wxruby' to 'wx' so code that requires 'wxruby' doesn't start breaking Smiley

Ruby is a great language, and having completed a decently large project in Ruby at the end of last year, I believe I can say that the arguments claiming it doesn't scale are simply false. Its elegant syntax and ease of readability make it actually easier to maintain, and so long as you follow proper software engineering principles like encapsulation and separation of concerns, I believe that rubya is at least as viable a language as the more enterprisey offerings like C# (and when Microsoft releases its implementation of ruby for the .NET framework, we'll have the best of both worlds Smiley ).

Enough ruby evangelizing. Let's get coding!
Logged
Kevin
Administrator
31337
*****

Karma: +1/-0
Posts: 137


View Profile WWW
« Reply #5 on: September 01, 2007, 12:53:56 AM »

Thanks for the update Nathan. I see more and more Ruby jobs on Craigslist all the time. I still haven't had a chance to play with it, but if it keeps growing like this I just might have to.
Logged

Pages: [1]
  Print  
 
Jump to: