dimanche 26 août 2018

checkbox in bucle for python 3.7

i'm creating check box in a grid. so that grid is progresive while i put a ID it show my the data from sqlite3, something like "facebook"

def consultar():

    label_buscar=Label(pes1, text="Buscar:").grid( row=0, column=0, padx=20, pady=30, ipadx=0, ipady=1)
    entry=Entry(pes1, width=15,justify='center',textvariable=cajaB)
    entry.grid( row=0, column=1)
    entry.bind("<KeyRelease>",buscar)
    Label(pes1, text="Ok").grid( row=1, column=0)
    Label(pes1, text="Rut",width=15).grid( row=1, column=1,)
    Label(pes1, text="Nombre",width=25).grid( row=1, column=2)
    Label(pes1, text="Telefono",width=15).grid( row=1, column=3)
    Label(pes1, text="Evolucion",width=25).grid( row=1, column=4)
    Label(pes1, text="Fecha", width=10).grid( row=1, column=5)
    Label(pes1, text="Hora", width=8).grid( row=1, column=6)
    Label(pes1, text="Carpeta", width=3).grid( row=1, column=7)
    Label(pes1, text="Fichero", width=3).grid( row=1, column=8)

def search(key)

   for cell in pes1.grid_slaves():
      if int(cell.grid_info()["row"]) >= 2:
        cell.grid_forget()

   contacto = Contacto()
   arreglo = contacto.buscar(cajaB.get())
   m=2
   n=1

   for c in arreglo:
       m=m+1
       n=n+1
       for r in range(n,m):
          for co in range(1, 9):

            cell = Entry(pes1, width=15,justify='center',font=("Calibri",10),disabledbackground="white",disabledforeground="black")
            cell.grid(padx=1, pady=1, row=r, column=co)
            cell.insert(END,c[co-1])
            cell.config (state = DISABLED )
            var = StringVar()
            cb = Checkbutton(pes1, command=checkbox, variable=var)
            cb.grid( row=r, column=0)                   

so i need what when someone click on a checkbox, that take a data from grid and call a funtion with that data take before.

see the image -->> image

i need do that coz when checkbox is on, check in my database if that data exits or not and when checkbox if off nothing happen

you can see in the image, when as i enter an id, show me how many people who have that id




Aucun commentaire:

Enregistrer un commentaire