This is a section from my code. Basically, I want access to the value given in the entry box, which is a part of the def init ..Is there any way around this without using global variables? Also, it is set up this way so that this variable can be used throughout my program. Thanks.
import tkinter as tk
class MainApp(tk.Tk):
def test():
a = __init__.test_entry.get()
print(a)
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
test_entry = tk.Entry(self)
test_entry.pack()
submit_button = tk.Button(self, text="Submit", command=MyApp.test)
submit_button.pack()
if __name__ == "__main__":
app = MainApp()
app.mainloop()