Search code examples
tkintergrid

tkinter's columnconfigure method(s)?


Are there any differences between columnconfigure, grid_columnconfigure, grid.columnconfigure, and grid columnconfigure in tkinter? I'm getting a little confused as there seems to be either different versions of this package or different documentations floating around, e.g. this one that appears to be some command line/shell language with no relation to Python.


Solution

  • From tkinter's source code (Python 3.9 it's line 1776):

    class Misc:
        ...
        def grid_columnconfigure(self, index, cnf={}, **kw):
            """Configure column INDEX of a grid.
    
            Valid resources are minsize (minimum size of the column),
            weight (how much does additional space propagate to this column)
            and pad (how much space to let additionally)."""
            return self._grid_configure('columnconfigure', index, cnf, kw)
    
        columnconfigure = grid_columnconfigure
    

    then on line 2499:

    class Grid:
        ...
        columnconfigure = grid_columnconfigure = Misc.grid_columnconfigure
    

    It shows you that they are the same exact functions

    The grid columnconfigure is actually not tkinter but tcl. It's what tkinter uses internally. You don't really need to know it.