[Tutor] Creating tables in Tkinter

Pooja Bhalode poojabhalode11 at gmail.com
Sun Feb 19 11:18:02 EST 2017


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)
Label
for i in range(1,11):

Label(root, text = i).grid(row = 1, column = i+1, sticky = W)
Label(root, text = i).grid(row = i+1, column = 0, sticky = W)

for j in range(1, 11):
Label(root, text = i*j).grid(row= i+1, column = j+1, sticky = W)
root.mainloop()

It opens a Tkinter window:
[image: Inline image 1]
So, here, how do I make the Table 1 span over the column range, or insert a
title: Table 1 multiplication table such that it doesn't affect the spacing
below. I am using grid packing in the code.

Also, how to make the labels for columns and rows: such that the labels are
placed in the centre of the range.

Thank you so much.

Pooja


More information about the Tutor mailing list