Copyright © tutorialspoint.com

Python - Tkinter grid() Method

previous next


This geometry manager organizes widgets in a table-like structure in the parent widget.

Syntax:

widget.grid( grid_options )

Here is the list of possible options:

Example:

Try following example by moving cursor on different buttons:

import Tkinter
root = Tkinter.Tk(  )
for r in range(3):
    for c in range(4):
        Tkinter.Label(root, text='R%s/C%s'%(r,c),
            borderwidth=1 ).grid(row=r,column=c)
root.mainloop(  )

This would produce following result displaying 12 labels arrayed in a 3 x 4 grid:

TK grid
previous next

Copyright © tutorialspoint.com