Python Forum
[Tkinter] Treeview automatically adjust it's size when pack inside frame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Treeview automatically adjust it's size when pack inside frame
#1
Hi guys, i have a question, i am creating a tkinter project where i will display data into tkinter window from database. For this i am using tkk treeview but as i run the code my treeview automatically adjusts it's height . It doesn't go according to the frame i am fitting my treeview into.
One more things i have created two frames for top and bottom but when i create button frames get shrinked to the size of button ? Why does it happen?
Please help

Below are codes
from tkinter import ttk

import tkinter as tk

import sqlite3

from tkinter import *

 

def View():

    conn = sqlite3.connect("99_data_increment.db")

    cur = conn.cursor()

    cur.execute("SELECT * FROM crawled")

    rows = cur.fetchall()

    for row in rows:

        tree.insert("", tk.END, values=row)

    conn.close()

 

root = tk.Tk()

root.geometry("1250x650+0+0")

root.title("MAYA")

root.configure(background="gray28")

 

Tops = Frame(root, width=1200, height=100,bd=14, relief="raise")

Tops.pack(side=TOP)

 

frame1 = Frame(root, width=1200, height=450,bd=15,relief="raise")

frame1.pack()

 

tree= ttk.Treeview(frame1, column=("column1", "column2", "column3", "column4", "column5","column6", "column7", "column8", "column9", "column10", "column11", "column12", "column13", "column14", "column15", "column16", "column17", "column18" ), show='headings')

tree.heading("#1", text="ID")

tree.heading("#2", text="STATE")

tree.heading("#3", text="XID")

tree.heading("#4", text="PROJECT NAME")

tree.heading("#5", text="CITY")

tree.heading("#6", text="MAIN CITY")

tree.heading("#7", text="REGISTRATION NUMBER")

tree.heading("#8", text="PROMOTER NAME")

tree.heading("#9", text="RERA URL")

tree.heading("#10", text="PDF NUMBER")

tree.heading("#11", text="CRAWLED DATE")

tree.heading("#12", text="STATUS")

tree.heading("#13", text="NAMES")

tree.heading("#14", text="TRANSACTION DATE")

tree.heading("#15", text="COMMENTS")

tree.heading("#16", text="CALL CONTACT NUMBER")

tree.heading("#17", text="CREATION TYPE")

tree.heading("#18", text="BUILDER WEBSITE")

tree.pack()

 

 

belows = Frame(root, width=1150, height=100, bd=14, relief="raise")

belows.pack(side=BOTTOM)

 

btnrefresh = Button(belows, fg="black", font=("arial", 8, "bold"),width=5,

                   text="REFRESH DATA", command=View).pack(side=LEFT)

 

root.mainloop()
Reply


Messages In This Thread
Treeview automatically adjust it's size when pack inside frame - by Prince_Bhatia - Jul-25-2018, 02:35 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Horizontal extension of widgets + frame size adapted to content Fab117 3 481 Feb-22-2024, 06:54 PM
Last Post: deanhystad
  [Tkinter] Help running a loop inside a tkinter frame Konstantin23 3 1,581 Aug-10-2023, 11:41 AM
Last Post: Konstantin23
  [Tkinter] Frame with treeview virencm 5 7,006 Feb-01-2022, 04:58 PM
Last Post: deanhystad
  [Tkinter] [split] Is there a way to embed a treeview as a row inside another treeview? CyKlop 5 3,378 Oct-20-2021, 12:14 AM
Last Post: CyKlop
  align frame inside canvas ro_btz 1 1,848 Sep-11-2020, 04:38 PM
Last Post: Larz60+
  [Tkinter] Trying to change font size w/o changing button size python63 3 9,871 Aug-05-2020, 01:04 AM
Last Post: Larz60+
  automatically generates a frame taratata2020 0 1,608 Apr-19-2020, 09:21 AM
Last Post: taratata2020
  [Tkinter] Treeview expand button size shamnadinn 8 7,719 Mar-08-2020, 12:02 PM
Last Post: shamnadinn
  [Tkinter] Scrollbar, Frame and size of Frame Maksim 2 9,023 Sep-30-2019, 07:30 AM
Last Post: Maksim
  [Tkinter] How to adjust time - tkinter Ondrej 2 2,864 Jun-20-2019, 05:53 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020