Section 9.1.

9.1. "Widgets and Gadgets and GUIs, Oh My!"

This chapter is a continuation of our look at GUI programming in Python. The previous chapter used simple widgetsbuttons, labels, and the liketo demonstrate the fundamentals of Tkinter coding in Python. That was simple by design: it's easier to grasp the big GUI picture if widget interface details don't get in the way. But now that we've seen the basics, this chapter and the next move on to present a tour of more advanced widget objects and tools available in the Tkinter library.

As we'll find, this is where GUI scripting starts getting both practical and fun. In these two chapters, we'll meet classes that build the interface devices you expect to see in real programse.g., sliders, check buttons, menus, scrolled lists, dialogs, graphics, and so on. After these chapters, the last GUI chapter moves on to present larger GUIs that utilize the coding techniques and the interfaces shown in all prior GUI chapters. In these two chapters, though, examples are small and self-contained so that we can focus on widget details.

9.1.1. This Chapter's Topics

Technically, we've already used a handful of simple widgets in Chapter 8. So far we've met Label, Button, Frame, and Tk, and studied pack geometry management concepts along the way. Although all of these are basic, they represent Tkinter interfaces in general and can be workhorses in typical GUIs. Frame containers, for instance, are the basis of hierarchical display layout.

In this and the following chapter, we'll explore additional options for widgets we've already seen and move beyond the basics to cover the rest of the Tkinter widget set. Here are some of the widgets and topics we'll explore in this chapter:

  • Top-level and Tk widgets

  • Message and Entry widgets

  • Checkbutton, Radiobutton, and Scale widgets

  • Images: PhotoImage and BitmapImage objects

  • Dialogs, both standard and custom

  • Widget configuration options

  • Low-level event binding

  • Tkinter variable objects

  • Using the Python Imaging Library (PIL) extension for other image types and operations

After this chapter, Chapter 10 concludes the tour by presenting the remainder of the Tkinter library's tool set: menus, text, canvases, animation, and more.

To make this tour interesting, I'll also introduce a few notions of component reuse along the way. For instance, some later examples will be built using components written for prior examples. Although these two tour chapters introduce widget interfaces, this book is really about Python programming in general; as we'll see, Tkinter programming in Python can be much more than simply drawing circles and arrows.

Programming Python
Programming Python
ISBN: 0596009259
EAN: 2147483647
Year: 2004
Pages: 270
Authors: Mark Lutz

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: