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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access