Chapter 15. Composite Widgets

So far, we have only discussed each basic widget separately. The Perl/Tk distribution also includes several composite widgets. Composite widgets are combinations of widgets that do something specific when they are combined. Here are some examples of composite widgets:

Optionmenu

Based on menubutton widget; it allows the user to select from a list of items on the menu.

LabEntry

Based on frame widget; it is an entry widget with a configurable label.

Dialog

Based on toplevel widget; it displays a bitmap and a message to the user.

I chose these examples because they demonstrate a good point about composite widgets. They can be based on a widget (in this case, menubutton), on a frame that contains widgets, or on a toplevel widget that contains other widgets and is a complete window.

When I first started learning about composite widgets, I always felt like I was missing something. If I looked at the code out of the corner of my eye, it made sense. Yet if I looked at it head on, I was suddenly utterly confused and wasn't sure what it was doing. The important thing to remember is that there is quite a bit that goes on behind the scenes that we take advantage of when we are creating a composite widget.

My goal with this chapter isn't for you to write the most complex type of composite widget you can think of. Simply understanding how composite widgets work is more than enough. You can build up slowly from there. The best thing to do is read through this ...

Get Learning Perl/Tk now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.