Sha256: f624196937bf4813dbe34a25a938f3cf6e45655e8bfb2b9a66ef5a3bc3493fcd

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

Shoes.app do
  background "#eee"
  @list = 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
        @list.append do
          stack do
            background "#eee".."#ccd"
            stack margin: 10 do
              dl = nil
              para @url.text, " [", link("cancel") { dl.abort }, "]", margin: 0
              status = inscription "Beginning transfer.", margin: 0
              p = progress width: 1.0, height: 14
              dl = download @url.text, save: File.basename(@url.text),
                                       progress: proc { |d|
                                         status.text = "Transferred #{d.transferred} of #{d.length} bytes (#{d.percent}%)"
                                         p.fraction = d.percent * 0.01
                                       },
                                       finish: proc { status.text = "Download completed" }
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoes-4.0.0.rc1 samples/simple_downloader.rb