Python Forum
[Tkinter] Does anybody know that how to edit tree view on tkinter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Does anybody know that how to edit tree view on tkinter
#5
Hi sir,

i have reached till here......

#C:/Users/prince.bhatia/Desktop/projects/Rera_App/project-3.py
import tkinter as tk
from tkinter import ttk

from pandastable import Table, TableModel

import sqlite3

import pandas as pd
import Backend

# --- classes ---

class MyTable(Table):

    def handleCellEntry(self, row, col):
        super().handleCellEntry(row, col)
        print('changed:', row, col, "(TODO: update database)")
        return

def save():
    print(df)
    result = df.to_sql("crawled", conn, if_exists="replace")
    print(result)

# --- main ---

root = tk.Tk()
#root.geometry("1250x650+0+0")
#root.title("MAYA")
#root.configure(background="black")

f = tk.Frame(root)
f.pack(fill="both", expand=True)

conn = sqlite3.connect("99_data_increment.db")
df = pd.read_sql_query("SELECT * FROM crawled", conn)

pt = MyTable(f, dataframe=df, showtoolbar=True, showstatusbar=True) # <-- MyTable
pt.show()

f = tk.Button(root, text="Save", command=save)
f.pack(fill="both", expand=True)

root.mainloop()
right now it is creating one index automatically and when i run the code


i am also attaching my backend code.

import sqlite3

def connect():
    conn=sqlite3.connect("99_data_increment.db")
    cur=conn.cursor()
    cur.execute("CREATE TABLE IF NOT EXISTS crawled (id INTEGER PRIMARY KEY, State , XID , Project_Name , City , Main_City , Registration_Number , Promoter_Name , Rera_URL , PDF_text, Crawled_Date , Status, Names, Transaction_Date, Comments, Call_Contact_Number, Creation_Type, Builder_Website)")
    conn.commit()
    conn.close()
    
def insert(State, XID, Project_Name, City, Main_City, Registration_Number, Promoter_Name, Rera_URL, PDF_text, Crawled_Date, Status, Names, Transaction_Date, Comments, Call_Contact_Number, Creation_Type, Builder_Website):
    conn=sqlite3.connect("99_data_increment.db")
    cur=conn.cursor()
    cur.execute("INSERT INTO crawled VALUES (NULL,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",(State, XID, Project_Name, City, Main_City, Registration_Number, Promoter_Name, Rera_URL, PDF_text, Crawled_Date, Status, Names, Transaction_Date, Comments, Call_Contact_Number, Creation_Type, Builder_Website))
    conn.commit()
    conn.close()

connect()
right now i have not received any error. I guess it is adding columns also when adding rows, not sure even
Reply


Messages In This Thread
RE: Does anybody know that how to edit tree view on tkinter - by Prince_Bhatia - Jul-27-2018, 04:35 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Cant set api response as tree in Element tree hey_arnold 4 3,861 Mar-04-2019, 03:25 PM
Last Post: dsarin
  [Flask] Create new project for add user,edit,delete,view users in python with mysql connector chandranmanikandan 0 7,541 Oct-30-2018, 10:19 AM
Last Post: chandranmanikandan

Forum Jump:

User Panel Messages

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