This code runs but crashes when I press the button it creates. It's my first post so If you have tips or If you need more info please comment. The program should save the variable of the boxes in global variable. But when I try to press button occur error.
from tkinter import *
finestra1 = Tk()
finestra1.title("Prima Finestra")
testo1 = Label(finestra1, text ="Inserire modello infissi").grid(row=0, column=0)
spazioinput1 = Entry(finestra1, width=10, borderwidth=5).grid(row=0, column=1)
testo2= Label(finestra1, text ="Inserire numero finestre").grid(row=1, column=0)
spazioinput2 = Entry(finestra1, width=10, borderwidth=5).grid(row=1, column=1)
testo3= Label(finestra1, text ="Inserire numero balconi").grid(row=2, column=0)
spazioinput3 = Entry(finestra1, width=10, borderwidth=5).grid(row=2, column=1)
def primobottone():
# global modelloinfissi
global numerofinestre
global numerobalconi
modelloinfissi = spazioinput1.get()
numerofinestre = int(spazioinput3.get())
numerobalconi = int(spazioinput2.get())
Label(finestra1, text="Modello: " +modelloinfissi +" \nnumero: "+ numerobalconi+numerofinestre)
bottone1 = Button(finestra1, text= "Avanti", command = primobottone).grid(row=3)
finestra1.mainloop()
The error I hit:
Error:
Exception in Tkinter callback
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/tkinter/__init__.py", line 1883, in __call__
return self.func(*args)
File "/Users/salvatorefroncillo/Desktop/progetto/progetto.py", line 18, in primobottone
modelloinfissi = spazioinput1.get()
AttributeError: 'NoneType' object has no attribute 'get'