- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Which widget do you use for an Excel-like table in Tkinter?
Tkinter is a standard Python library that is used to build featured GUI-based desktop applications. Tkinter itself offers a variety of functions and widgets that can be used to design and serve the application's needs.
Tkinter Treeview widget is one of the consistent widgets which is used for driving the data and information in the form of a table. It works similar to MS Excel where we can add or define columns, insert some values to it, and perform queries in the backend using other Python libraries (such as Numpy or Pandas).
Tkinter Treeview widget is created by defining the Treeview(parent, column=(**col), **options) constructor. Now we can add columns and insert values to it.
# Import the required libraries from tkinter import * from tkinter import ttk # Create an instance of tkinter frame win= Tk() # Set the size of the tkinter window win.geometry("700x350") # Add a Treeview widget tree= ttk.Treeview(win, column=("c1", "c2","c3"), show= 'headings') tree.column("# 1",anchor=CENTER) tree.heading("# 1", text= "ID") tree.column("# 2", anchor= CENTER) tree.heading("# 2", text= "FName") tree.column("# 3", anchor= CENTER) tree.heading("# 3", text="LName") # Insert the data in Treeview widget tree.insert('', 'end',text= "1",values=('XYZ', 'ABC','123')) tree.pack() win.mainloop()
Running the above code will display a table-like window with columns and entries for the row.
- How to open an Excel Spreadsheet in Treeview widget in Tkinter?
- How do you check if a widget has a focus in Tkinter?
- How to use the Entry widget in Tkinter?
- How to use a StringVar object in an Entry widget in Tkinter?
- Creating an Excel-like data grid in React JS
- How do you use Vernier caliper for an accurate measurement of distance?
- How to set focus for Tkinter widget?
- Creating a table look-a-like using Tkinter
- Notebook widget in Tkinter
- How to disable an Entry widget in Tkinter?
- How do you OR two MySQL LIKE statements?
- How do I get an event callback when a Tkinter Entry widget is modified?
- How do you use ‘foreach’ loop for iterating over an array in C#?
- Progressbar widget in Python Tkinter
- How do I center the text in a Tkinter Text widget?