O'Reilly logo

Sams Teach Yourself Ruby in 21 Days by Mark Slagell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Entry Widgets and Buttons

Let's look at a slightly more sophisticated script. Suppose we want to take a pair of phrases and determine whether they are anagrams of each other—that is, whether the letters of one phrase can be rearranged to form the other phrase, ignoring spaces and punctuation.

The algorithm for determining whether two strings are anagrams is quite easy, so we'll leave that aside for now and concentrate on the graphic interface. We obviously need two text entry fields, and for these we'll use TkEntry widgets. Each will be labeled suitably with a TkLabel widget. Finally we'll use a TkVariable to associate a Ruby variable with a text field, although this is more of an implementation detail than a matter of appearance.

You're not ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required