[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版

(yzsuai) #1

CHAPTER 9


A tkinter Tour, Part 2


“On Today’s Menu: Spam, Spam, and Spam”


This chapter is the second in a two-part tour of the tkinter library. It picks up where
Chapter 8 left off and covers some of the more advanced widgets and tools in the tkinter
arsenal. Among the topics presented in this chapter:


  • Menu, Menubutton, and OptionMenu widgets

  • The Scrollbar widget: for scrolling text, lists, and canvases

  • The Listbox widget: a list of multiple selections

  • The Text widget: a general text display and editing tool

  • The Canvas widget: a general graphical drawing tool

  • The grid table-based geometry manager

  • Time-based tools: after, update, wait, and threads

  • Basic tkinter animation techniques

  • Clipboards, erasing widgets and windows, and so on
    By the time you’ve finished this chapter, you will have seen the bulk of the tkinter
    library, and you will have all the information you need to compose larger, portable user
    interfaces of your own. You’ll also be ready to tackle the larger GUI techniques and
    more complete examples presented in Chapters 10 and 11. For now, let’s resume the
    widget show.


Menus


Menus are the pull-down lists you’re accustomed to seeing at the top of a window (or
the entire display, if you’re accustomed to seeing them that way on a Macintosh). Move
the mouse cursor to the menu bar at the top and click on a name (e.g., File), and a list
of selectable options pops up under the name you clicked (e.g., Open, Save). The op-
tions within a menu might trigger actions, much like clicking on a button; they may

507

Do


wnload from Wow! eBook <www.wowebook.com>

Free download pdf