Day of Ruby (Part 3)
May 20th, 2009Due 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.
- Shoes runtime.
- Working shoe applications. The applications end in .shy.
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):
