2008/09/21

Shoes widget with block

I attempted to write a tiny sample code for learning about Shoes widget with block.
# widget_with_block.rb
class Creature < Widget
def initialize
msg = para '', :stroke => white
c = image Dir.pwd + '/yar.png'
yield c, msg
end
end

Shoes.app :width => 140, :height => 70 do
flow :left => 10, :top => 10 do
background blue.to_s..green.to_s, :width => 100,
:height => 30
creature do |c, msg|
c.click do
msg.text = 'Uhhhh...'
a = animate(20){|i| c.rotate(-15);
a.remove if i > 22}
end
c.hover{msg.text = 'hello'}
c.leave{msg.text = ''}
end
end
end




Is this useful... or not? :-P

ashbb

No comments:

O'Reilly Ruby Books

Twitter Updates

    follow me on Twitter