I have the following function:
def Buscar(self):
comando="SELECT * FROM tipo_inversion where id='"+self.palabra.get()+"';"
conectar=Base_de_datos.BaseDeDatos()
conectar.cursor.execute(comando)
#rows= conectar.cursor.fetchall()
for dat in enumerate(conectar.cursor.fetchall()):
self.listbox.insert(0, Label(self.listbox, text=dat[0]))
self.listbox.insert(1, Label(self.listbox, text=dat[1]))
self.listbox.insert(2, Label(self.listbox, text=dat[2]))
self.listbox.insert(3, Label(self.listbox, text=dat[3]))
I'm using a cycle to accommodate 4 data that I have in a table in postgresql, but I really do not know if I'm fine like that, I get this error:
self.listbox.insert(1, Label(self.listbox, text=dat[2]))
IndexError: tuple index out of range
I used to have only the listbox and with fetchall, I used to call self.listbox.insert(0, *rows)
the number of rows is mentioned in the first function
but I do not like how the data shows, since they look very close and I want them to have a bit of space, so try the cycle and create a label. For this, I base myself on this code:
Label(self.ventanaBusqueda, text=dat[0]).grid(row=index+1, column=0)
Label(self.ventanaBusqueda, text=dat[1]).grid(row=index+1, column=1)
Label(self.ventanaBusqueda, text=dat[2]).grid(row=index+1, column=2)
Label(self.ventanaBusqueda, text=dat[3]).grid(row=index+1, column=3)
and putting it this way, I can not accommodate it where I have the listbox, that is the position.