

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 can I set the row height in Tkinter TreeView?
The treeview widget in Tkinter provides a way to represent the data in a hierarchical structure. With the Treeview widget, we can insert our data in the form of a table. The table can have rows and columns in which we can insert the data instantly.
We can also configure the properties of the treeview widget such as its color, size, column width, height, row width & height, etc. To set the row height of the Treeview widget, you can create an instance of ttk themed widget where you can specify the rowheight property. The rowheight property will add internal padding to each row in the table.
Example
# 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 the rowheight s.configure('Treeview', rowheight=40) # 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()
Output
If we run the above code, it will display a window with a table and some data in it. In the given table, each row has an assigned row height.
- Related Questions & Answers
- How I can set the width and height of a JavaScript alert box?
- How to set the Row Height of a JTree with Java?
- How to disable multiselection on Treeview in tkinter?
- How to set the height/width of a Label widget in Tkinter?
- How do I get the width and height of a Tkinter window?
- How to clear an entire Treeview with Tkinter?
- Delete and Edit items in Tkinter TreeView
- How to change the background color of a Treeview in Tkinter?
- How can I set an ImageView's width and height programmatically in Android?
- How can I resize the root window in Tkinter?
- How to correctly select multiple items with the mouse in Tkinter Treeview?
- How can I get android device screen height, width?
- How can I set the default value of my Tkinter Scale widget slider to 100?
- How do I set browser width and height in Selenium WebDriver?
- How can I set an ImageView's width and height programmatically in Android using Kotlin?
Advertisements