the program supposed to search insideof an exel file with input of the first and sec name, if the child is there it will reply but if the child is not there it will ask the user if he wants to add him. everything works fine but i cant hide the "yes" button for some reason
yes=Button(text="yes",command=lambda: yesBot(ChildGym,firstNameLabel1,secNameLabel1))
yes.grid(row=4,column=4)
this is the entire code for thos who wondring;
import pandas as pd
from tkinter import *
import tkinter.messagebox
root=Tk()
ChildGym = pd.read_excel('TheGloriousEvolution.xlsx')
def findchild(): #check if child is inside excel file
firstNameLabel1=firstNameEntry.get()
secNameLabel1=secNameEntry.get()
for index, row in ChildGym.iterrows():
if not firstNameLabel1:
ans.configure(text="pls enter child first name")
answer=True
break
if not secNameLabel1:
ans.configure(text="pls enter child sec name ")
answer=True
break
if row['FirstName']==firstNameLabel1 and row['SecName']==secNameLabel1:
ans.configure(text="all good!")
answer=True
break
else:
ans.configure(text="the kid is not here")
answer=False
if answer==False:
yes=Button(text="yes",command=lambda: yesBot(ChildGym,firstNameLabel1,secNameLabel1))
yes.grid(row=4,column=4)
nobot.grid(row=4,column=3)
askMan.grid(row=4,column=2)
else:
answer=True
def yesBot(ChildGym,firstNameLabel1,secNameLabel1):
ChildGym_new_row = pd.DataFrame({ 'FirstName': [firstNameLabel1], 'SecName': [secNameLabel1] })
ChildGym=pd.concat([ChildGym,ChildGym_new_row], axis=0)
ans2.configure(text="kid got added succesfully!")
ChildGym.to_excel("TheGloriousEvolution.xlsx", index=False)
def noBot():
askMan.grid_forget()
nobot.grid_forget()
# botton "click me" to do the def "find child"
Bot=Button(root,text="click me",command=findchild)
Bot.grid(row=0,column=4)
#label to ask if he wants to add the user
askMan=Label(text="do you want to add this child?")
#button to press no if you dont want to add this child
nobot=Button(root,text="no",command=noBot)
# label and entry for the first name
firstNameLabel=Label(text="what is the first name of the kid you want to search?")
firstNameLabel.grid(row=0,column=0)
firstNameEntry=Entry(root)
firstNameEntry.grid(row=0,column=1)
# labels to give answer if the kid is inside the excel file
ans=Label(root)
ans.grid(row=0,column=2)
# labels to give answer if they added to the excel file
ans2=Label(root)
ans2.grid(row=4,column=1)
# label and entry for the second name
secNameLabel=Label(text="what is the sec name of the kid you want to search?")
secNameLabel.grid(row=1,column=0)
secNameEntry=Entry(root)
secNameEntry.grid(row=1,column=1)
root.mainloop()