How to access variables from outside the interface How to access variables from outside the interface tkinter tkinter

How to access variables from outside the interface


You can acces your variables with that code below:

from tkinter import *root = Tk()s_n = Entry(root)n_o_p = Entry(root)s_t = Entry(root)f_n = Entry(root)c = Entry(root)s_n.insert(0,"Enter Subreddit name")n_o_p.insert(1,"Enter number of posts")s_t.insert(2,"Enter search type")f_n.insert(3,"Enter flair tpye")c.insert(4,"Enter amount of comments")s_n.pack()n_o_p.pack()s_t.pack()f_n.pack()c.pack()def myclick():    global s_n    s_n = s_n.get()myButton = Button(root, text="Enter: ", command=myclick)myButton.pack()root.mainloop()print(s_n)