Re.Mark

My Life As A Blog

Ruby Tuesday #11 Update : First Steps with Shoes

with one comment

When I left my last post, I had been encountering some crashes with Shoes.  So, I took the Ruby code I’d written, installed Shoes on a Mac (running Leopard) and, hey presto, it worked.  I haven’t tested another Vista PC to see if it’s Shoes or the PC I was using.  Here’s the code:

require 'Twitter'

translator = Translator.new
client = Client.new

Shoes.app :title => "Twitter Shoes", :height => 750, :width => 750 do
  background rgb(240, 250, 208 )
  stack :width => 700, :height => 1.0, :margin => 20 do
    background "#eee", :radius => 12
    border "#00D0FF", :strokewidth => 3, :radius => 12
    stack :margin => 20 do
      button "Get Timeline" do
        alert("Username is {#@username.text} and password is {#@password.text}")
        timeline = ""
        translator.xml_to_tweets(client.download_friends_timeline(@username.text, @password.text)).each do |tweet|
        timeline << "#{tweet.user.screen_name} says #{tweet.text}\n\n"
      end
      @label.replace timeline
      #alert "done"
    end
  end
  stack :height => 550, :margin => 20 do
    background "#eee"
    @label = para ""
  end
  stack :margin =>20 do
    @username = edit_line :height =>50, :width => 100
    @password = edit_line :secret => true, :height =>50, :width => 100
   end
 end
end

So, what needs to be done next now is to provide a way to tweet from the Shoes form.  And it could do with some tidying up.

To help if you’re following this series, I’ve posted the source files for Twitter.rb and App.rb.

Oh, and there’s a space between 208 and the closing bracket in the line beginning background because if I don’t put the space in, WordPress converts the sequence 8 followed by a bracket to a smiley face wearing sunglasses.  Like this 8) .  Which looks a bit weird in code.

Advertisements

Written by remark

June 24, 2008 at 10:11 pm

One Response

Subscribe to comments with RSS.

  1. Wow, you are the first person that I have seen use windows live spaces for storing files… I did not know that was possible. Its a good start for the app, I have been looking at doing something similar myself, but I figure I should probably learn some more ruby first before actually trying (and failing very badly) to do something.

    SeanJA

    June 25, 2008 at 5:58 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: