: ¿No logro aplicar Update con Button a registro en Tkinter y Psycopg2?
Publicado por jorge (6 intervenciones) el 07/12/2018 17:11:20
Estoy tratando de actualizar columna Postgresql,Tkinter, con boton en toplevel
son solo tres campos(id, nombre, salario), solo quiero al editar registro cambiar nombre y salario, pero no me esta aplicando los cambios, me sale error:
son solo tres campos(id, nombre, salario), solo quiero al editar registro cambiar nombre y salario, pero no me esta aplicando los cambios, me sale error:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
TypeError: edit_records() missing 3 required positional arguments: 'nombre', 'new_salario', and 'salario' cuando aplico [] a la funcion lambda o TypeError: argument 1 must be a string or unicode object: got tuple instead, con () al llamar la funcion.
def edit_empleado(self):
self.message['text'] = ''
try:
self.tree.item(self.tree.selection()) ['values'] [0]
except IndexError as e:
self.message['text'] = 'Por Favor Selecione el Empleado'
return
nombre = self.tree.item(self.tree.selection())['text'] #[0]
salario = self.tree.item(self.tree.selection())['values'][0]
self.edit_wind = Toplevel()
self.edit_wind.title('Editar Empleados')
# Old Tipo Documento
Label(self.edit_wind, text = 'nombre Actual:').grid(row = 0, column = 1)
Entry(self.edit_wind, textvariable = StringVar(self.edit_wind, value = nombre), state = 'readonly').grid(row = 0, column = 2)
# New tipo documento
Label(self.edit_wind, text = 'Nuevo nombre empleado:').grid(row = 0, column = 3)
new_nombre = Entry(self.edit_wind)
new_nombre.grid(row = 0, column = 4)
# Old numero Documento
Label(self.edit_wind, text = 'salario Actual:').grid(row = 1, column =1)
Entry(self.edit_wind, textvariable = StringVar(self.edit_wind, value = salario), state = 'readonly').grid(row = 1, column = 2)
# New numero documento
Label(self.edit_wind, text = 'Nuevo salario:').grid(row = 1, column = 3)
new_salario= Entry(self.edit_wind)
new_salario.grid(row = 1, column = 4)
# Nuevo primer Nombre
Label(self.edit_wind, text='================').grid(row=6, column=2)
Button=ttk.Button(self.edit_wind, text='ACTUALIZAR ', command = lambda : self.edit_records ([new_nombre.get(), nombre, new_salario.get(), salario]))
Button.grid(row=7, columnspan=2, ipady=7, sticky=E)
def edit_records(self, new_nombre, nombre, new_salario, salario):
query =("select * from empleado for update",
(new_nombre, nombre, new_salario, salario))
parameters = (new_nombre, new_salario, nombre, salario)
self.run_query(query, parameters)
self.edit_wind.destroy()
self.message['text'] = 'Empleado {} Actualizado Satisfactoriamente'.format(nombre)
self.get_empleados()
if __name__ == '__main__':
window = root()
application = Empleado(window)
window.mainloop()
Valora esta pregunta
0