Ruby is not only showing its power in Rails but also applications like “shoes” ,”shoes” is graphics and windowing toolkit. It will run on all platforms like Windows, Mac OS X and Linux , which help you to build desktop applications easily.Its creating GUI components some what similar to web applications.shoes library making our task easier by providing lots of methods to build a desktop item.Ruby Shoes is written in C and uses Ruby native extensions to allow interaction with Ruby code.
First of all you need to install ruby “shoes” ,available here download
1.Download source
2.Extract(unzip)
3.Install
Now run
$ shoes
Which will give take you to a graphical mode there you can choose your ruby file for shoes.Or run your shoes file by
$ shoes <filename.rb>
Here is examples to show the simplicity and elegance of ruby shoes.Start with a small ones
Example for a button click
Shoes.app {
button("Hello") { alert("You have clicked on hello") }
}
example for drop down box
shape = nil
Shoes.app do
shape = list_box :items => ["Square", "Oval", "Rectangle"]
button "Report" do
Shoes.p [shape.text]
end
end
You can see all the methods available for shoes “CLICK ME” or type on command line
$ shoes --manual - you can see a helper.
Ideal example to see the power of shoes is given below , in those few lines its doing a big job !!
Shoes.app :width => 500, :height => 100, :margin => 10 do
def answer(v)
@answer.replace v.inspect
end
button "Ask" do
answer ask("Enter your name")
end
button "Confirm" do
answer confirm("Like to proceed??")
end
button "Open File" do
answer ask_open_file
end
button "Save File" do
answer ask_save_file
end
button "Select Your Color" do
answer ask_color("Select yours")
end
@answer = para "Answers appear here"
end
1 response so far ↓
1 dict.org client with Ruby Shoes // May 2, 2008 at 10:45 am
[…] It dumps the meaning of the word as well as similar words from thesaurus on to the terminal. Now my idea was to build a simple GUI to ‘dict’. To do it in a flash, i decided to use Ruby Shoes, a light weight GUI tool kit in Ruby. More about Shoes and its installation can be read from Divya’s article on Shoes. […]
Leave a Comment