Welcome folks today in this blog post we will be creating table layout widget with scrollbar and display data
in tkinter
gui desktop app in python. All the full source code of the application is given below.
Get Started
In order to get started you need to install the below library using the pip
command as shown below
pip install tkinter
After installing this library you need to make an app.py
file and copy paste the following code
app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# Python program to create a table from tkinter import * class Table: def __init__(self,root): # code for creating table for i in range(total_rows): for j in range(total_columns): self.e = Entry(root, width=20, fg='blue', font=('Arial',16,'bold')) self.e.grid(row=i, column=j) self.e.insert(END, lst[i][j]) # take the data lst = [(1,'Raj','Mumbai',19), (2,'Aaryan','Pune',18), (3,'Vaishnavi','Mumbai',20), (4,'Rachna','Mumbai',21), (5,'Shubham','Delhi',21)] # find total number of rows and # columns in list total_rows = len(lst) total_columns = len(lst[0]) # create root window root = Tk() t = Table(root) root.mainloop() |
If you execute the above python script
by typing the below command
python app.py