Tkinter GUI Programming
Examples on Tkinter
Display Data Datagrid Tkinter
To display the Data in table or datagrid in python first we need to import tkinter module and frame window need to create for GUI.
Treeview is being created as in the following example. We can put the heading names as column shown in following example. Later you can assign the values with associated fields as we explained in the following examples. The Table may have dynamic heading and data as well selected from database.
To test the live example try the following code and you will see the table with data as in below image.
You can also see the post here in tkinter like calculator , login page , insert delete update in single page etc.
Full Database based GUI applications you can create using TKinter and database like MYSQL etc.
To display data in Tkinter Grid following code may be used
try:
from tkinter import *
from tkinter.ttk import *
except ImportError :
print("exception in importing module")
class MyWindow(Frame):
def CreateUI(self):
tv = Treeview(self)
tv['columns'] = ('Name', 'Mobile', 'course')
tv.heading("#0", text='RollNo', anchor='w')
tv.column("#0", anchor="w")
tv.heading('Name', text='Name')
tv.column('Name', anchor='center', width=100)
tv.heading('Mobile', text='Mobile')
tv.column('Mobile', anchor='center', width=100)
tv.heading('course', text='course')
tv.column('course', anchor='center', width=100)
tv.grid(sticky = (N,S,W,E))
self.treeview = tv
self.grid_rowconfigure(0, weight = 1)
self.grid_columnconfigure(0, weight = 1)root = Tk()
MyWindow(root)
root.mainloop()