GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: a tiny graphical app kit for ruby
Homepage: http://code.whytheluckystiff.net/shoes
Clone URL: git://github.com/why/shoes.git
commit  c147140320e487f210ee5520f03c549b1b9ad929
tree    6a402d8964c9ff779394f8eca232a154f22cf78a
parent  f6fd3b1eb5247a623e6ac8894daffd7bde3be05e
shoes / samples / simple-downloader.rb
100644 28 lines (27 sloc) 0.965 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Shoes.app do
  background "#eee"
  stack do
    para "Enter a URL to download:", :margin => [10, 8, 10, 0]
    flow :margin => 10 do
      @url = edit_line :width => -120
      button "Download", :width => 120 do
        parent.append do
          stack do
            background "#eee".."#ccd"
            stack :margin => 10 do
              dl = nil
              para @url.text, " [", link("cancel") { dl.abort }, "]", :margin => 0
              d = inscription "Beginning transfer.", :margin => 0
              p = progress :width => 1.0, :height => 14
              dl = download @url.text, :save => File.basename(@url.text),
                :progress => proc { |dl|
                  d.text = "Transferred #{dl.transferred} of #{dl.length} bytes (#{dl.percent}%)"
                  p.fraction = dl.percent * 0.01 },
                :finish => proc { |dl| d.text = "Download completed" }
            end
          end
        end
      end
    end
  end
end