Getting interactive help

This section is not just true about Tkinter, but for any Python object for which you need help.

Let's say you need a reference on Tkinter Pack geometry manager, you can get interactive help in your Python interactive shell using the help command, as shown in the following command lines:

>>> import Tkinter
>>> help(Tkinter.Pack)

This provides a detailed help documentation on all the methods defined under the Pack class in Tkinter.

You can similarly view help for all other individual widgets. For instance, you can check comprehensive and authoritative help documentation for Label widget in the interactive shell by typing:

>>>help(Tkinter.Label)

This provides a list of:

  • All methods defined in class Label
  • All standard and widget specific options for Label widget
  • All methods inherited from other classes

Finally, when in doubt about a method, look into the source file located at <location-of-python-installation>liblib-tkTkinter.py.

Tip

The lib-tk directory is the home to some great Tkinter code that you can study. In particular, you may also want to take a look at the source code of:

  • turtle.py: A popular way to introduce programming to kids. It includes some cool animated effects
  • Tkdnd.py: An experiment code that lets you drag and drop items on the Tkinter window.

You might also find it useful to look at the source code implementation of various other modules, such as the color chooser, file dialogs, ttk module, and others.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.170.134