There are two issues in your code:
all Entry
widgets are local variables inside inputFunc()
which cannot be accessed inside addClientFunc()
. You can move addClientFunc()
into inputFunc()
as a nested function.
all the entry variables are assigned the result of place()
, so they are all None
. You need to separate the line like idEntry = Entry(...).place(...)
into two lines: idEntry = Entry(...)
and idEntry.place(...)
.
Below is the modified code:
def inputFunc():
def addClientFunc():
ins_table_Clients.insert_one({
"c_id": idEntry.get(),
"c_name": nameEntry.get(),
"c_firmName": firmNameEntry.get(),
"address": addressEntry.get(),
"engine": engineEntry.get(),
"power": powerEntry.get(),
"phoneNumber": phoneNumberEntry.get(),
"email": emailEntry.get(),
"workHour": workHourEntry.get()
})
inputWindow = Tk()
inputWindow.title("Mü?teri Ekleme Ekran?")
inputWindow.geometry("500x500")
submitButton = Button(
inputWindow,
text = "Mü?teriyi Ekle",
width = 30,
height = 5,
fg = "DarkOrange1",
bg = "green3",
command = addClientFunc)
submitButton.place(x=150,y=350)
Label(inputWindow, text = "Mü?teri Numaras?").place(x = 30,y = 50)
Label(inputWindow, text = "Mü?teri Ad?").place(x = 30,y = 70)
Label(inputWindow, text = "Firma Ad?").place(x = 30,y = 90)
Label(inputWindow, text = "Adres").place(x = 30,y = 110)
Label(inputWindow, text = "Motor Markas?").place(x = 30,y = 130)
Label(inputWindow, text = "Motor Gücü").place(x = 30,y = 150)
Label(inputWindow, text = "Telefon Numaras?").place(x = 30,y = 170)
Label(inputWindow, text = "E-mail").place(x = 30, y = 190)
Label(inputWindow, text = "?al??ma Saati").place(x = 30,y = 210)
idEntry = Entry(inputWindow)
idEntry.place(x = 180, y = 50)
nameEntry = Entry(inputWindow)
nameEntry.place(x = 180, y = 70)
firmNameEntry = Entry(inputWindow)
firmNameEntry.place(x = 180, y = 90)
addressEntry = Entry(inputWindow)
addressEntry.place(x = 180, y = 110)
engineEntry = Entry(inputWindow)
engineEntry.place(x = 180, y = 130)
powerEntry = Entry(inputWindow)
powerEntry.place(x = 180, y = 150)
phoneNumberEntry = Entry(inputWindow)
phoneNumberEntry.place(x = 180, y = 170)
emailEntry = Entry(inputWindow)
emailEntry.place(x = 180, y = 190)
workHourEntry = Entry(inputWindow)
workHourEntry.place(x = 180, y = 210)
inputWindow.mainloop()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…