What graphical toolkits exist with "good" Ruby bindings? - ruby

I want to create a tool with Ruby which works with all 3 of the major OSes (Windows, Linux, Mac OS X). What choices do I have for toolkits where the bindings for Ruby is "good"? By good I mean not just quick direct mapping of the C/C++ API onto Ruby, for instance using blocks where appropriate and other Ruby features.

I would say QTRuby (so bindings for QT) seem to be the most advanced and also quite cross platform without requiring some pre-installed virtual machine - like in the case of Ruby (JRuby Java Swing Bridge - another very good solution if the user already has Swing know-how)

Until recently, pretty much the best options were Swing and SWT. And you know that there is something seriously wrong if Swing is your best option. But now, there's also WPF.
All three, Swing, SWT and WPF work great on Windows, OSX, Linux and probably a dozen others.

For OS X I would say MacRuby - http://www.macruby.org/ because of HotCocoa http://www.macruby.org/hotcocoa.html

By far the most thoroughly supported is Tk (Ruby/Tk: http://ruby-doc.org/docs/ProgrammingRuby/html/ext_tk.html), and it'll run on just about anything. Down side is, it isn't very pretty.
Here's another good guide for using Ruby/Tk: _http://www.tutorialspoint.com/ruby/ruby_tk_guide.htm
If you're looking for something a little nicer looking, try gtk(2): _http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk

Related

Doing native GUI with Ruby

I'd like to develop a desktop app with Ruby. However, I'd like to have a native GUI on every platform (as opposed to a cross-platform GUI Toolkit that looks consistently awful across all platforms).
I expect to have to do different GUIs for each platform (as it's not just looks but also behaviors and idioms that are different), but I wonder what my options are? Especially wondering if there is a clean way to separate front and backend and bind the data properly?
Target Platforms are Windows (Vista & 7, XP is a Bonus), Mac OS X (Cocoa) and Linux (GTK? Qt? No idea).
The Ruby language has excellent Qt library bindings and your scripts will be cross-platform.
Two Kinds of Cross-Platform
It turns out there are two kinds of cross-platform UI toolkits.
One kind draws its own controls, and, like you said, looks equally bad on all platforms. Even worse: it looks out-of-place on all except one.
But there is another kind that just provides a harmonized interface to the native widgets. The best of example of this kind of toolkit is SWT1.. It looks, it is, approximately fully native on each platform, yet it has but a single API.
So you shouldn't simply rule-out all cross-platform toolkits, just rule out the ones that fake the native UI.
Develop the Wrapper Interface
There is a second way. If your program's interface with the user can be directed through a relatively narrow interface, you can simply develop to that interface and then implement the bottom part of it for each platform you want to support. Yes, you have to rewrite one module, but all the other modules stay exactly the same and you get native widgets. You also get the smallest possible executable without lots of bloat.
Perhaps most importantly, you don't have a complex and opaque software layer between your code and the native windowing system. You will probably save as much time debugging as you spend writing the extra module for your first port.
1. I know my Java examples won't help you much unless you are using jRuby, but SWT vs Swing is a really pure example of the right-vs-wrong (IMHO) UI toolkit divide.
The WxWidgets interface claims to use the native interface on Windows, OS X, Linux and UNIX through one API.
Coworkers who have used it in the past enjoyed it well enough, but I've not used it myself.

Creating Ruby applications for Windows

I want to develop a Windows application. Honestly I care little about cross-platforms for now (but still would be good)
I want to use Ruby, since it has quite a simple syntax and is so.. well, simple and easy to learn.
My application is like a "game level creator", where you can design your own level and then run it with another application which is a "game level player" by reading the project file created by the creator app. You get the idea.
Now, I got a new PC and is completely clean. Absolutely no trace of my old Ruby experiments and fails.
First of all, I will need to choose a GUI platform for my Ruby application! Can you recommend me one? I have heard of Shoes and Tk, but want to know what you think.
Have you considered IronRuby? It's an implementation of Ruby that runs on the .Net platform, which means you have access to all of the standard Windows Forms libraries, if you decide to run in Windows. http://ironruby.net/
According to david4dev, it also runs well on Mono, which makes it great for cross-platform compatibility, as the Mono platform runs on Mac OSX and Linux, as well as Windows.
Jorg W Mittag says that using the WPF (Windows Presentation Framework) is an even better option for creating GUI's since Mono has a very strong implementation of the WPF. The WPF was created to be platform agnostic and is better suited for cross-platform development over WinForms, since WinForms is tightly coupled with the Windows OS.
I recommend using Shoes out of the 2. Shoes is a nice simple way to build small applications using Ruby. The reason why Shoes is better than TK for your application is that it makes it very simple to create graphics.
Shoes is well suited to small apps and it will be quite hard to create a game creator using it.
You are probably better off using an SDL based game framework such as Rubygame . This works on Linux, Windows and OSX.
For the simple, typical editing most GUI kit will do just fine. However, for the more complicated (and especially the level creation/editing) you're mostly gonna end up using a lot of self-made rendering in DirectX/OpenGL.
I don't know a lot about Ruby though, but I'd consider GUI kits Or frameworks with that aspect in mind.
Just thought I'd share my 2 cents :)

Rich and widely used Ruby GUI framework for Windows?

I read about wxRuby and Shoes but never used them. I want to learn ruby by developing a real-world serious Windows application. Among the available frameworks, which one is widely used and acceptable, rich in libraries and comes bundled with .exe builder?
There aren't a great deal of sensible choices for client/desktop applications in Ruby right now, however I believe one of your best options is to take advantage of mature JVM libraries via JRuby.
The Redcar text editor is written in Ruby and runs on the JVM, and you can view the source on Github here https://github.com/danlucraft/redcar
There is also a development company called Atomic Object that made a neat Ruby desktop app using JRuby with a fairly sophisticated GUI and you can view that here.
I've been thinking about the exact same problem as you and keeping and eye on my the options, these last few months :-)
I've also been using JRuby on the server-side and it's solid and reliable.
Finally, if it's Windows-only as you say, then you could consider using a .NET GUI Framework like WPF and build it using IronRuby, however IronRuby is not yet as mature as JRuby, so you could be exposing yourself to some risk there in terms of compatibility, bugs and performance (and for the record, I like IronRuby!).
However, the potential issues of using IronRuby might be balanced out by the gains you'd make using a GUI framework that's designed and optimised for Windows and is nicer than Swing. WPF is about as rich as it gets for GUI frameworks on Windows.
There are bindings for Qt on GitHub. I believe it's a fork from the Korundum bindings from KDE. However, I haven't tried it on Windows yet.
You might consider using RubyTk. Tk is a toolkit that works with many languages including ruby. For more information see tkdocs.com
disclaimer: I have no idea how widely used it is, though Tk in general is used in many places for both commercial, internal and open source projects.
http://en.wikibooks.org/wiki/Ruby_Programming/GUI_Toolkit_Modules will help
In terms of popularity, in 2008 shooes was most popular, but that has probably dropped.
http://www.pressure.to/ruby_gui_survey/
Since RubyInstaller project bundles now complete modern Tk distribution and bindings eliminating Windows installation woes- Tk seems the way to go.
With RubyGems I believe it is now possible to install GTK+ for this. So says this in Gems. This is a widely used framework, both in open source and industry. It is used in GIMP and, I think, presents a good windows system that is close to native and easily useable.

Is Smalltalk a viable development language for Mac OS X?

Every time I see a discussion on software development, always someone suggests or exalts the qualities of Smalltalk, be it the beautiful language constructs or the better implementation of basically everything.
So I was curious, is anybody developing in Smalltalk? can Smalltalk actually be used to develop software on the Mac? Or what is the target platform for Smalltalk? What is the poster child for this apparently fantastic but unpopular language?
Smalltalk isn't really used for GUI application development on the Mac in any major way. The only distribution that could produce native apps was Ambrai Smalltalk, and that died in beta AFAIK. Squeak is the most popular Smalltalk variant nowadays, but you will be torn limb from limb if you release a Mac OS X app that looks like Squeak. It's worth checking out if you're interested in learning the language (which is still unique in a lot of ways), but you're probably not going to be developing OS X apps with it.
If you would like something similar, check out MacRuby. Ruby is as close as you can get to Smalltalk without actually being Smalltalk — total object orientation, dynamic, 100% message-based, heavy use of blocks, etc. MacRuby is an implementation being developed by Apple specifically for making OS X applications.
Mac OS X's native Objective-C is also heavily Smalltalk-inspired (it's basically a big chunk of Smalltalk's object system and syntax bolted onto C), but owing to its extreme C compatibility, it falls a little further from the tree.
Take a look at fscript, which is essentially a smalltalk-like language for Objective C.
Luis: do you want to do desktop application for Mac ? or you want to program in Mac? If you want to do a web application for example, you can perfectly use Squeak or Pharo. If you want to do native mac applications, you should see the Mars project for Squeak:
http://smallworks.com.ar/productos/Mars
As an example, most of the Pharo users and developers are under Mac.
http://www.pharo-project.org/home
download and try it at least for a couple of hours!
I still believe that Squeak is well worth investigating, if only to broaden your mind a little. As for the poster child for Smalltalk, it's probably Seaside.
Squeak isn't its UI. You can configure Morphic heavily (look at how similar Pharo's is to OSX, for instance). Or you can just use native widgets with wxSqueak.
This deserves some attention:
"Objective-Smalltalk was created specifically to solve practical problems that have been encountered in 25 years of Objective-C and Smalltalk use, but with a theoretical framework that solves many of these problems elegantly and minimally, rather than by bolting on special feature after special feature."
http://objective.st/

Can Ruby be used for UI based Windows apps?

I'm sorry if this question is noob-ish but I'm not having much luck with Google. Can Ruby be used for UI based Windows apps? I'm not looking for a Rails app, just Ruby.
Thanks
You have couple of options.
Use Gtk Ruby which works on Windows as well (http://ruby-gnome2.sourceforge.jp/).
You can use WxRuby or Tk.
You can use JRuby and Swing.In fact there are high level libraries which can help you there, such as (http://monkeybars.rubyforge.org/)
Yes, but the experience will vary depending on how you hook up the UI. TK or gtk, wxRuby, ruby shoes (not sure how alive that one is right now), Qt (which is cool) and fox (aka fxRuby) are some of the options. If you like to hurt yourself, you can hook directly to Win32 libraries, but I doubt you'll want to.
Additionally, if you target the nascent IronRuby, you can use WinForms or WPF.
I also prefer wxRuby. It looks great, uses native components, yet is cross-platform. On the Ruby On Windows blog there is a great write-up of how to get started. It helped me a lot.
You bet. wxRuby is what I use, but others use GTK. wxRuby also works on Linux which is where I am writing a program, but it should suit your needs. You can install it using
gem install wxruby
You could check out wxRuby..
Depends what kind of Window app are you going to implement. If this is your own pet project, then definitely you can try WxRuby or GTK. There is no risk here.
However if this is going to be serious, commercial windows app then you have to think twice. It is really worth using Ruby? It is great language. I use it on daily basis. But for a Windows app, C# integration with the whole environment is hard to beat.
check out Shoooes!

Resources