MI codigo es programa que guarda, busca y edita inventario. Estoy intentando usar TKINTER para poder crear una interfaz. Pero tengo un problema al intentar juntar ambas. Las funciones sin TKINTER funcionan pero al intentar juntarlos estoy con algunos problemas. La verdad no sabria que parte estaria mal como tal. Por ello muestor el codigo entero.
EL CODIGO ES MAS LARGO PERO CREO QUE ESTO ES MAS QUE SUFICIENTE
import pickle
import tkinter
def main():
def nuevaven1(): #Agregar objeto a diccionario
ventana.withdraw()
win=tkinter.Toplevel()
win.geometry('520x350')
codigoas=tkinter.Label(win, text="Ingrese Codigo:",width=30)
codigoas.place(x=20,y=30)
codigoen=tkinter.Entry(win, text="",width=30)
codigoen.place(x=300,y=30)
descripcio=tkinter.Label(win, text="Ingrese Descripcion:",width=30)
descripcio.place(x=20,y=70)
descripcioen=tkinter.Entry(win, text="",width=30)
descripcioen.place(x=300,y=70)
cantidad=tkinter.Label(win, text="Ingrese cantidad:",width=30)
cantidad.place(x=20,y=110)
cantidaden=tkinter.Entry(win, text="",width=30)
cantidaden.place(x=300,y=110)
def agregar(dic):
x = codigoen.get()
y = descripcioen.get()
z = cantidaden.get()
dic[x] =[y,z]
confirmar=tkinter.Button(win, text="Confirmar",width=30,command=agregar)
confirmar.place(x=290,y=150)
ventana =tkinter.Tk()
ventana.config(bg='#CBE0F3')
ventana.geometry('520x350')
ventana.resizable(0,0)
ventana.title('Inversan')
agregarb=tkinter.Button(ventana, text="Agregar",width=30,command=nuevaven1)
agregarb.place(x=290,y=150,)
editarb=tkinter.Button(ventana, text="Editar",width=30)
editarb.place(x=290,y=210)
buscarb=tkinter.Button(ventana, text="Buscar",width=30)
buscarb.place(x=290,y=270)
ventana.mainloop()
if __name__ == '__main__':
main()
Como vieron algunas partes solo funcionan con funciones pero esta en trabajo solo queiro saber como arreglar mi error que esta en la funcion nuevaven1 y en la funcion agregar.
FUNCIONA LA INTERFAZ DE TKINTER pero al ingresar datos a la funcion agregar y guardar los datos suelta un error. Nose porque o como arreglarlo Este es mi código pero tengo un error que es el siguiente:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Pedro Santos\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1892, in __call__
return self.func(*args)
TypeError: agregar() missing 1 required positional argument: 'dic'