Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

39 lines (28 sloc) 1.24 kb

Downloader

This method starts a download thread running in the background and displays a handy progress bar. Please keep in mind that the 'percent' and 'length' methods don't seem to work well at this time, whereas 'transferred' and 'fraction' do.

# sample28.rb
Shoes.app :width => 450, :height => 100 do
  stack :margin => 10 do
    url = 'http://www.rin-shun.com/shoes/shoes-0.r1263.exe'
    status = para "Downloading #{url}"
    p = progress :width => 1.0

    download url,
      :save => Dir.pwd + '/' + File.basename(url),
      :start => proc{|dl| status.text = 'Connecting...'},
      :progress => proc{|dl| 
        status.text = "Transferred #{dl.transferred} of #{dl.length} bytes (#{dl.percent}%)"
        p.fraction = dl.percent * 0.01},
      :finish => proc{|dl| status.text = 'Download finished'},
      :error => proc{|dl, err| status.text = "Error: #{err}" }
  end
end

sample28.png

sample28.png

Shoes includes the Hpricot library for parsing HTML.
For more information about downloader, please consult the Shoes manual.

Policeman

The sample28.rb worked well with Shoes-0.r1263.

Jump to Line
Something went wrong with that request. Please try again.