Bottom Page

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()
Quote
#2
With proper use of grid geometry and sizing weights you can control geometry in tkinter, but it's quite difficult to get it right. This is the main reason why I switched to wxpython phoenix where resizing, docking and undocking, and many other things are so much easier, not to mention the large library of widgets. Qt5 is also a great GUI library, written in C, but has excellent python support (pyQt5), and reciently announced even greater support for python.

I use either a tkinter treeview or list view in this program: https://github.com/Larz60p/CaliforniaPublicSalaries
and figured out pretty much how to properly size the view. But even here, resizing doesn't work properly.
You might be able to garner something from this, it was written quite a while ago, so not so sure of it's value.

This would have been a one night project if I had used wxpython.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [Tkinter] Scrollbar, Frame and size of Frame Maksim 2 173 Sep-30-2019, 07:30 AM
Last Post: Maksim
  [PyQt] How to populate a treeview on a GUI with a dictionary mart79 1 362 Aug-05-2019, 01:30 PM
Last Post: Denni
  [Tkinter] How to adjust time - tkinter Ondrej 2 247 Jun-20-2019, 05:53 PM
Last Post: Yoriz
  [Tkinter] Not getting entry values on button click & treeview not updating ? swanysto 4 786 May-10-2019, 04:16 PM
Last Post: swanysto
  [Tkinter] Image does not show in treeview. KevinBrown 3 460 May-05-2019, 11:47 PM
Last Post: KevinBrown
  [Tkinter] create and insert a new frame on top of another frame atlass218 4 633 Apr-18-2019, 05:36 PM
Last Post: atlass218
  [Tkinter] TKK, tree.pack and get size from os diegoctn 2 356 Feb-15-2019, 02:38 PM
Last Post: diegoctn
  [Tkinter] Tkinter timetabl using treeview mntfr 3 383 Feb-05-2019, 09:36 PM
Last Post: Larz60+
  [Tkinter] I need to know how to put my SQLite3 data into a Treeview Thename921 1 1,072 Jan-12-2019, 10:26 PM
Last Post: Larz60+
  video player inside a frame/panel in python raspberry pi desktop application MATHEWS 1 502 Dec-12-2018, 11:42 AM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)