[Tutor] Creating tables in Tkinter
Alan Gauld
alan.gauld at yahoo.co.uk
Mon Feb 20 05:00:50 EST 2017
On 19/02/17 16:18, Pooja Bhalode wrote:
> Hi,
>
> I am trying to create a simple table. But I was wondering how do I get the
> title of the table to span over multiple columns in the first row.
> Code:
>
> from Tkinter import *
>
> root = Tk()
> root.geometry("700x500")
> Label(root, text = "Table 1").grid(row = 0, column = 0, sticky = W)
grid has many attributes, you can see them using the help() function:
-------------
Help on function grid_configure in module tkinter:
grid_configure(self, cnf={}, **kw)
Position a widget in the parent widget in a grid. Use as options:
column=number - use cell identified with given column
(starting with 0)
columnspan=number - this widget will span several columns
in=master - use master to contain this widget
in_=master - see 'in' option description
ipadx=amount - add internal padding in x direction
ipady=amount - add internal padding in y direction
padx=amount - add padding in x direction
pady=amount - add padding in y direction
row=number - use cell identified with given row (starting with 0)
rowspan=number - this widget will span several rows
sticky=NSEW - if cell is larger on which sides will this
widget stick to the cell boundary
-----------------
Notice the columnspan option.
set it to the number of columns in your table.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list