Shoes GUI question - downloading body of sites using Ruby


#1

Hi all,

I want to use shoes to be able to download the body of a website that a
user enters in an edit_line. How can I make this work? Can anyone help
explain why the below code does not work? It just pops up a new window,
and does not download the site from the text entered…

Here’s my code thus far:

Shoes.app do
  stack (:left => 175, :top => 200) do
    para "Enter a url:"
    flow do
      @url = edit_line
      button "OK" do

    window do
        stack do
         title "Searching site", :size => 16
          @status = para "One moment..."
           # Search site for query and print body
            download @url.text do |site|
              @status.text = "Body: " + site.response.body.inspect
           end
        end
      end
    end
  end
end

end


#2

On Sun, Oct 12, 2008 at 03:52:58PM +0900, Double M. wrote:

I want to use shoes to be able to download the body of a website that a
user enters in an edit_line. How can I make this work?

You’re very, very close. The problem is that instance variables
aren’t shared between windows. You can use a normal variable url
or, if you really need to use an instance variable, you can use
owner.instance_variable_get("@url") to get to it.

A good section to read in the docs is the “Block Redirection”
stuff, basically the first two sections on this page:
http://help.shoooes.net/Rules.html

_why