Chapter 11. Custom Widgets and Classes: With an object in mind

image with no caption

Requirements can be complex, but programs don’t have to be.

By using object orientation, you can give your programs great power without writing lots of extra code. Keep reading, and you’ll create custom widgets that do exactly what you want and give you the power to take your programming skills to the next level.

The DJ wants to play more than one track

The World Music Mixing Expo is only a few weeks away. Your DJ friend is thrilled with the work you’ve done, but now he has a few extra requirements.

Just playing one track isn’t enough. To be useful, the program needs to be able to mix several tracks together at the same time. Each track needs its own graphical interface elements (or widgets).

How will you create the widgets for each track?

To play and control a single track, you created two widgets on the GUI: a check button to start and stop the track and a scale to change the volume. Then you added event-handling code to hook those widgets up to the sound system.

image with no caption
image with no caption

To play multiple tracks together, you just need more of the same. Each track will need its own set of widgets and its own event handlers to connect the widgets and the ...

Get Head First Programming 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.