With the code you need extracted from the nongraphical application and added to your GUI program, press F5 in IDLE to see (and hear) if things are working any better now:

l-t rioĆ® only looks good, but now it sounds good, -too!

Every time you click on a button, the appropriate sound effect is heard. Great work!

Dumb Questions

So "event handlers" in tkinter are just functions?

This actually isn't too hard. I always thought building a GUI was only for advanced programmers?

A" Well... that certainly used to be the case, but things have changed (for the better). Technologies like tkinter allow every programmer to build great-looking GUIs without too much fuss. It's a case of tkinter concentrating on the GUI, while you concentrate on your code.

A" Yes, as we said earlier in this chapter: it's alljust code. And by putting the code you want to run in a function, it's easy to reference it using the command parameter associated with each button. Your user clicks the button to run the code in your function.

And is it the case that, if I want to add other things to my GUI program, it's done in a similar way?

Yes, all you have to do is write the code.

Q/ And I connect my code up to my other things using something like the command parameter that works with buttons?

A" Yes, that's all there is to it. The mechanism for the other interface elements (or widgets, for short) might be a little different, but the concept is the same. Once you can work with one, the rest are a lot easier to get your head around.

missing results

Was this article helpful?

0 0

Post a comment