I'd like to live prototype GUIs with Macruby. Like creating a window, placing some views in it, etc.. Is that possible?
3 Answers
Yes it is.
Have a look at the HotCocoa documentation: http://www.macruby.org/hotcocoa.html

- 943
- 7
- 19
Yes! I just figured this out myself, so I thought I'd share (even though this is an old question). I'm assuming you have MacRuby installed (I'm using 0.11).
Install HotConsole. HotConsole is an IRB-like thing that runs MacRuby code. The nice thing is that it is multithreaded, which means the HotCocoa app doesn't block the console. To install just:
% git clone git@github.com:altirah/hotconsole.git hotconsole
% cd hotconsole
% macrake
You can then drag the HotConsole.app to your /Applications folder.
In HotConsole, you can store a HotCocoa window in a variable and then play around with it. For example, in HotConsole.app (make sure you use alt-Enter to go to a new line, else you will run what you've typed so far):
win = window frame: [100, 100, 500, 500], title: 'Hello' do |w|
w << label(text: 'Hello', layout: {start: false})
end
You should see a nice Cocoa window pop up with a label that says 'Hello'. Now for the fun part. In HotConsole.app, you can now type:
win << button
win << web_view( :layout => {:expand => [:width, :height]},
:url => "http://macruby.org")
HotConsole is pretty crashy for me, but I'm using a not-yet-released version of MacRuby to build/run it, so I don't know if that makes a difference.

- 715
- 7
- 15
You can, however, since all the code runs in the main thread it would block the runloop and thus views won't behave as they should.
I’ve been working on and off on another project that does allow you to do this, the only thing that's important is to note that in this case all user code is run in separate threads, so you should dispatch a message on the main thread when interacting with other views: https://github.com/alloy/interactive-macruby

- 20,908
- 2
- 30
- 40