Chapter 12. 11 widgets, events, and emergent behavior: Getting Interactive
Figure 12-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.”
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