Day of Ruby (Part 3)

2009 May 20
by Joe

Due to difficulties getting Cucumber working on three different operating systems and various versions of Ruby gems, the next two sections were rather accelerated.

The next topic that Cory discussed involved creating client applications with a basic UI tool kit called Shoes.

Three shoe applications were shown: a simple button click application, a simple Hello World application using a stack and a more complicated binary clock.

Here’s the source code for the Hello World application using a stack. Stacks are used to organized layouts. In Java AWT (abstract window toolkit) terms, it is similar to a panel. It servers as a container that holds UI components and displays them by specified layout.

File: layout.rb

Shoes.app do

  background '#EFC'
  border 'BE8', :strokewidth => 6

  stack(:margin => 12) do
    para 'Enter your name'

    flow do
      @name = edit_line
      @ok = button 'OK'
    end
  end

  @ok.click do
    @name.text = "Hello #{@name.text}"
  end

end

Executing this application using Shoooes displays (without the name Joe pre-filled):

shoooes_20090520

No comments yet

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS