- 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
How to correctly select multiple items with the mouse in Tkinter Treeview?
The purpose of Tkinter Treeview widget is to provide the user to access the data which can be calculated and modified for the future needs of the application. The Treeview widget is used to populate the given data in a table format. We can add or insert a column, insert data into rows. Sometimes, there might be a case when we want to select multiple rows at a time. This can be done by pressing the Ctrl key and selecting the row from the table.
# 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") s = ttk.Style() s.theme_use('clam') # Add a Treeview widget tree= ttk.Treeview(win, column=("c1", "c2","c3"), show= 'headings', height= 5) 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=('1', 'Joe','Nash')) tree.insert('', 'end',text= "2",values=('2', 'Emily','Mackmohan')) tree.insert('', 'end',text= "3",values=('3', 'Estilla','Roffe')) tree.insert('', 'end',text= "4",values=('4', 'Percy','Andrews')) tree.insert('', 'end',text= "5",values=('5', 'Stephan','Heyward')) tree.pack() win.mainloop()
Running the above code will display a table containing multiple entries in it.
You can select multiple rows at a time by pressing the Ctrl key and selecting the row from the table.
- Delete and Edit items in Tkinter TreeView
- How to clear an entire Treeview with Tkinter?
- How to remove multiple selected items in the listbox in Tkinter?
- How to move a Tkinter canvas with Mouse?
- How to disable multiselection on Treeview in tkinter?
- How to change the background color of a Treeview in Tkinter?
- How can I set the row height in Tkinter TreeView?
- How to change the mouse pointer color in Tkinter?
- Changing the Mouse Cursor in Tkinter
- How to draw a line following mouse coordinates with tkinter?
- How to add a column to a Tkinter TreeView widget?
- How to hide or disable the mouse pointer in Tkinter?
- How to open an Excel Spreadsheet in Treeview widget in Tkinter?
- How to select multiple elements with jQuery?
- Mouse Position in Python Tkinter