每次插入

时间:2016-09-17 07:48:48

标签: python sqlite treeview

您好我在插入值后尝试刷新表值时遇到问题我确实找到了向表中插入值的方法但是我在向表中添加一行后面临问题我必须关闭软件并且重新开始

class mainGui(ttk.Frame):
def __init__(self):
    Frame.__init__(self,background="lightblue")
    self.master.title("Family book library")
    self.pack(expand=1, fill=BOTH)
    toolBar = Frame(self)


    self.buttonPicRef = PhotoImage(file="Refresh.png")
    ref = ttk.Button(toolBar, image= self.buttonPicRef)
    ref.pack(side=LEFT)

    self.buttonPicInsert = PhotoImage(file="insert.png")
    addbook = ttk.Button(toolBar,image = self.buttonPicInsert,command = self.fitcher)
    addbook.pack(side=LEFT)

    self.buttonPicAnalyse = PhotoImage(file="analys.png")
    analysis = ttk.Button(toolBar, image = self.buttonPicAnalyse,command = analysFun)
    analysis.pack(side=LEFT)

    self.buttonPicSearch = PhotoImage(file="search.png")
    search = ttk.Button(toolBar, image = self.buttonPicSearch)
    search.pack(side=LEFT)
    toolBar.pack(side=LEFT)

    menu = Menu(self.master)
    self.master.config(menu=menu)
    file = Menu(menu)
    file.add_command(label="Exit", command=quit)
    menu.add_cascade(label="File", menu=file)


    tree = ttk.Treeview(show="headings", height=32)
    tree["columns"] = ("1", "2", "3", "4", "5", "6", "7" ,"8")

    tree.column("1", width=132)
    tree.column("2", width=302)
    tree.column("3", width=302)
    tree.column("4", width=142)
    tree.column("5", width=123)
    tree.column("6", width=120)
    tree.column("7", width=120)
    tree.column("8", width=120)

    tree.heading("1", text="BookID")
    tree.heading("2", text="BookTitle")
    tree.heading("3", text="BookAuthor")
    tree.heading("4", text="BookPublisher")
    tree.heading("5", text="edition")
    tree.heading("6", text="PublisherDate")
    tree.heading("7", text="familyOwner")
    tree.heading("8", text="Location")




    conn = sqlite3.connect('books.sqlite')
    c = conn.cursor()

    count = c.execute('SELECT count(*) FROM library')
    countf = c.fetchall()
    num = countf[0][0]

    totle = c.execute('SELECT * FROM library')
    totlef = c.fetchall()

    rows = None
    for rows in range(0, num):
         rows

    for values in totlef:
         values[0]
         values[1]
         values[2]
         values[3]
         values[4]
         values[5]
         values[6]
         values[7]
         tree.insert('', rows,values=(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]))

    conn.commit()
    conn.close()


    tree.pack(side=TOP)

软件正常启动但顶级窗口的更新未显示告诉用户关闭并打开我想启动一个新的Button buttonPicRef

0 个答案:

没有答案