Jul-25-2018, 02:35 AM
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
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()