Currently I am working on my first project with tkinter. The main window should include a Button which opens a new window. In this new window I want the user to fill in some text. By clicking on a save-button the entered text should somehow be saved globally and then the window should be closed. I would be very happy if you could help me at least with the saving issue!
In my current code it tells me 'NoneType' object has no attribute 'get'. I think that is because the save button only takes the text in the textfield in the version it is, when opening the second window. So it does not take the data which has been entered by the user.
Code:
from tkinter import *
window = Tk()
window.title("Window 1")
window.geometry("400x300")
def save(a):
print(a)
def show_window():
window2 = Tk()
window2.title("Window 2")
window2.geometry("400x50")
label1 = Label(window2, text="Insert Text").grid(row=0)
text1 = Entry(window2).grid(row=0, column=1)
save_button = Button(window2, text="Save", command=lambda:
save(text1.get())).grid(row=2, column=0, columnspan=2)
button1 = Button(window, text="push",
command=show_window).grid(row=6, column=0, sticky="E")
mainloop()