Running with Shoes - Tasty Text

The Shoes toolkit has a nice rich text format support. At first sight it might seem that Shoes text support borrows a lot from HTML, for example the most commonly used text block is para. In addition to the paragraph text block, you can use banner, title, subtitle, tagline, caption, and inscription.

shoes toolkit text block

As you can see banner is the largest text block, followed by tittle, etc. The default size for banner, title, subtitle, tagline, caption, para, and inscription is 48, 34, 26, 18, 14, 12, 10 pixels respectively. You can also change the default size of a text block by using the optional size parameter.

Most often you will use the paragraph text block. If you have to display a great amount of text on a paragraph you pass in variable number of strings parameters.

In addition to text blocks, Shoes supports text formats such as strong, em, code, ins, span, sub, and sup. Here is an example of using a paragraph block with all of the text formats.

shoes toolkit text format

In addition to simple text blocks and text formatting methods, you can create hyper links. Just like the hyper web, links can execute some event or code.

The above code creates a link and assigns it to the hyper_link variable. The link is later passed on to the paragraph block for display. If you click on the link ‘link pressed’ will be printed on the terminal console.

In addition to executing custom code when a link is pressed, you can also launch the default browser if you use the click parameter. The code below displays a link and when pressed it will launch the Firefox or your default browser to the given URL.

All the text formatting methods also accept an option stroke parameter to sent the color. Here is a simple example of using color with your text.

Here is a recap of the available methods for working with text with the Shoes toolkit.

Text Blocks:
para, banner, title, subtitle, tagline, caption, inscription

text formats:
strong, em, del, ins, link, span, sub, sup

There are more Shoes GUI tutorials and code samples here.

Technorati Tags: , , , , , ,

YouTube and Picasa Web API Hackathon »
« Peopleware
 
Related Posts
Recent Posts
 

1 Comment so far

  1. Jónas Tryggvi on March 27th, 2008

    Hey, I’ve been using your ralis plugins, such as acts_as_commentable and acts_as_votable, and I have made several changes to them - both so they work with rails 2.0 and perform better.. are you interested in getting patches or ideas sent to you?

    Cheers,
    Jónas Tryggvi

Leave a reply