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
  [PyQt] Size Policy, Laout and Official Documentation Man_from_India 4 108 Jul-15-2019, 03:17 PM
Last Post: Denni
  [Tkinter] sleep(n) not working inside tkinter mainloop roger31415 2 144 Jul-14-2019, 06:57 PM
Last Post: wuf
  TKinter GUI / Pandas Data frame Loop NSearch 0 126 Jun-26-2019, 12:37 AM
Last Post: NSearch
  [Tkinter] How to adjust time - tkinter Ondrej 2 158 Jun-20-2019, 05:53 PM
Last Post: Yoriz
  [Tkinter] changing the frame colour nick123 2 280 May-14-2019, 02:48 PM
Last Post: nick123
  [Tkinter] Not getting entry values on button click & treeview not updating ? swanysto 4 370 May-10-2019, 04:16 PM
Last Post: swanysto
  [Tkinter] Image does not show in treeview. KevinBrown 3 251 May-05-2019, 11:47 PM
Last Post: KevinBrown
  [Tkinter] How do I stop window changing size? microphone_head 1 159 May-02-2019, 11:34 AM
Last Post: microphone_head
  [Tkinter] adapt management grid mode to management pack mode atlass218 4 284 Apr-24-2019, 11:04 AM
Last Post: atlass218
  [Tkinter] create and insert a new frame on top of another frame atlass218 4 325 Apr-18-2019, 05:36 PM
Last Post: atlass218

Forum Jump:


Users browsing this thread: 1 Guest(s)