0
Every time I press the "Query" button treeview updates, but also by adding previous Rows.
def consultar():
#função que Mostra na treeview todos os produtos cadastrados
conn = sqlite3.connect('banco_produtos_cadastrados.db')
bd = conn.cursor()
bd.execute("SELECT * FROM produtos")
rows = bd.fetchall()
for row in rows:
print(row) # Mostra toda tabela
tree.insert("", tk.END, values=row)
tree= ttk.Treeview(janela2, column=( "column1", "column2", "column3", "column4", "column5","column6"), show='headings')
ttk.Style().configure(tree, background = "black", foreground="white", fieldbackground="red")
tree.heading("#1", text="código")
tree.heading("#2", text="Produto")
tree.heading("#3", text="Marca")
tree.heading("#4", text="Fornecedor")
tree.heading("#5", text="Preço")
tree.heading("#6", text="Preço do fornecedor")
tree.pack()
Wouldn’t it be the case to clean the tree before a new query? Or create an algorithm capable of checking the excess items? I didn’t understand your problem.
– Caio de Paula Silva
yes, really it would be the case to clean the tree. could help me with that?
– Eduardo Teixeira
That help you?
– Caio de Paula Silva
Problem solved. Mega grateful!
– Eduardo Teixeira
Great! Feel free to post the answer or delete the question if you consider that it is too specific to serve other users.
– Caio de Paula Silva