saush

Singapore.rb meeting presentation slides and source code

Posted in Ruby by sausheong on April 20, 2007

I’m pretty glad to say that the Singapore.rb event went rather well today. The crowd was quite respectable, I think, maybe around 20+ people in all were there, old and new. Meeting up with people from just curious to looking around for programmers were quite heartening, from the days when it was just Choon Keat and I pinging each other on my blog and then over email.

Anyway for the participants of the even today, here are my slides in PDF.

FxRuby and Screensvr slides

And here are the source code:

This is a the sample code in Ruby/Tk.

require 'tk'

root = TkRoot.new
button = TkButton.new(root) {
    text "Click me"
    command proc { puts "Hello world!" }
}
button.pack
Tk.mainloop

This is the sample code in wxRuby.

require 'wx'
include Wx

class FxApp < App
 def on_init
  frame = Frame.new nil, -1, "Wx2 Hello"
  panel = Panel.new frame, 1
  button = Button.new panel,  2, "Click me"
  button.evt_left_down() { | event | puts "Hello world!"  }
  frame.show
 end
end
FxApp.new.main_loop

This is the sample code in Ruby-GTK2.

require 'gtk2'
include Gtk

window = Window.new
window.signal_connect("destroy") { Gtk.main_quit }
button = Button.new "Click me"
button.signal_connect("clicked") {  puts "Hello world!" }

window.add button
window.show_all

Gtk.main

This is the sample code in FxRuby.

require 'fox16'
include Fox

app = FXApp.new

main = FXMainWindow.new app, "Fx Hello"
button = FXButton.new main, "Click me!"
button.connect(SEL_COMMAND) {  puts "Hello world!" }
app.create

main.show PLACEMENT_SCREEN

app.run

This is the slightly more complex code in FxRuby.

require 'fox16'
require 'fox16/colors'
require 'fox16/kwargs'
include Fox

app = FXApp.new

main = FXMainWindow.new(app, "Fx Hello",
                             :opts  => FXTopWindow::DECOR_ALL,
                             :width => 200,
                             :height => 100)

pane = FXText.new(main, :opts => LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT|LAYOUT_TOP|FRAME_NORMAL,
                         :width => 200,
                         :height => 55) {|pane| pane.backColor = FXColor::White }

slider = FXSlider.new(main, :opts => LAYOUT_FIX_WIDTH|LAYOUT_BOTTOM,
                            :width => 200,
                            :height => 15) {|slider| slider.value = 0}

slider.connect(SEL_COMMAND) {  pane.text = "Argh! You let go!" }
slider.connect(SEL_CHANGED) {  pane.text = "Current slider value: #{slider.value}" }
app.create

main.show PLACEMENT_SCREEN

app.run

Finally the complex looking graphics manipulation sample application you saw is actually glviewer.rb in the samples code in the FxRuby install.

You can download FxRuby from http://www.fxruby.org.

Hope everyone had fun!

Singapore.rb event at the National Library

Posted in Rails, Ruby by sausheong on April 2, 2007

The Singapore.rb is going to have a meeting at the National Library on 19 April. The NLB has provided us with a room enough for 50 odd people and wifi-access. It’s going to be a general get-together plus a sharing session. Two speakers has been confirmed more or less — Choon Keat, who will be talking about KRJS and hpricot_forms and myself, who will be talking about FxRuby and Screensvr. Yes, one is about Rails and the other is about Ruby (not Rails). It should be fun and I hope it’ll be start of many more meetings to come, so join us if you’re around in Singapore!

For more information, check on this thread regularly!

Follow

Get every new post delivered to your Inbox.

Join 447 other followers