Question

Having just started to learn ttk on Python 3 (using tkdocs), I am having a hard time locating the docs for certain widgets (Python-only), when I want to get in more details than the text reveals.

For example, in the Docs, I cannot find the breakdown for the ttk.Frame class. I would've been interested to understand what the 'sticky' parameter does in:

mainframe.grid(column=0, row=0, sticky=(N, W, E, S))

Attempting to ask the interpreter:

from tkinter import ttk
help(ttk.Frame.grid)

returns:

'Help on function grid_configure in module tkinter' 

(so, not ttk).

This is but an example, to underline my "quest" to find the "full" Python API breakdown for the tk/ttk bindings.

Was it helpful?

Solution

Many ttk objects are just thin wrappers over existing Tkinter objects, so the Tkinter descriptions will be what you are looking for. One good place to look is An Introduction to Tkinter (on effbot.org). There are other good references listed at the top of the main Tkinter page in the Python docs (the page before the one you linked to). The New Mexico Tech docs are quite extensive and recently updated too.

To get a lower level view of how ttk objects are based on Tkinter objects, look in the ttk source code in C:\PythonXX\Lib\tkinter\ttk.py. Here you'll see that ttk.Frame is just based on a tkinter widget and there are no further methods or attributes defined.

The "sticky" parameter is actually part of the grid geometry manager and says what side of the parent container an object should "stick" to, with options given as compass points. "NW" means "top left". The effbot Grid page gives a good breakdown of all of these options.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top