I'm currently learning Tkinter and working on a small SQLite database application for managing client information. I've encountered a couple of issues that I'm seeking assistance with:
Extra Column in Tkinter Treeview:
In my application, I've set up a ttk.Treeview to display client information. However, I notice that there is an extra column appearing in the table, and I'm unsure why this is happening.
Alignment Issue in SQLite Database:
Additionally, when I save information to the SQLite database and retrieve it to display in the ttk.Treeview, there seems to be an alignment issue. The data is not displaying correctly in the respective columns, and there appears to be a misalignment.
I've tried adjusting column widths and alignments, but the problems persist. I'm reaching out to the community for guidance on identifying and resolving these issues.
def lista_frame2(self):
self.listaCli = ttk.Treeview(self.frame_2, height=3, columns=("col0", "col1", "col2", "col3"))
self.listaCli.heading("#0", text="Código", anchor=CENTER)
self.listaCli.heading("col1", text="Nome", anchor=CENTER)
self.listaCli.heading("col2", text="Telefone", anchor=CENTER)
self.listaCli.heading("col3", text="Cidade", anchor=CENTER)
self.listaCli.column("#0", width=50, anchor=CENTER)
self.listaCli.column("col1", width=50, anchor=CENTER)
self.listaCli.column("col2", width=50, anchor=CENTER)
self.listaCli.column("col3", width=60, anchor=CENTER)
self.listaCli.place(relx= 0.025, rely= 0.05, relwidth= 0.92, relheight= 0.90)
self.scrollLista = Scrollbar(self.frame_2, orient = 'vertical')
self.listaCli.configure(yscroll=self.scrollLista.set)
self.scrollLista.place(relx= 0.945, rely= 0.05, relwidth= 0.03, relheight= 0.90)
self.listaCli.bind("<Double-1>", self.OnDoubleClick)

What I've Tried:
- Adjusted column widths in the
ttk.Treeviewto ensure they are appropriate for the content. - Set
anchor=CENTERfor column headings to center-align the text. - Checked for any extra spaces or characters in the data retrieved from the SQLite database.
Expectation:
- I expected the
ttk.Treeviewto display only the specified columns without any additional ones. - I expected the data retrieved from the SQLite database to be correctly aligned within their respective columns in the
ttk.Treeview.