O'Reilly logo

Head First Learn to Code by Eric Freeman

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

Chapter 13. 11 widgets, events, and emergent behavior: Getting Interactive

Image
Figure 13-1. This is a hardcore programming chapter. Work hard, get sleep, drink water, have patience, stick with it—you’ll come out the other side having unlocked the next level!

You’ve certainly written some graphical applications, but you haven’t created a real user interface yet. That is, you haven’t written anything that lets the user interact with a graphical user interface (otherwise known as a GUI). To do that you need to adopt a new way of thinking about how a program executes, one that is more reactive. Wait, did the user just click on that button? Your code better know how to react and what to do next. Coding for interfaces is quite different from the typical procedural method we’ve been using, and it requires a different way of thinking about the problem. In this chapter you’re going to write your first real GUI, and no, we’re not going to write a simple to-do list manager or height/weight calculator, we’re going to do something far more interesting. We’re going to write an artificial life simulator with emergent behavior. What does that mean? Well, turn the page to find out.

Note

Pronounce GUI like “gooey.”

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