It looks like you may be confused as to when commands are run. In your example, you are calling the
get method before the GUI has a chance to be displayed on the screen (which happens after you call
Try adding a button that calls the
get method. This is much easier if you write your application as a class. For example:
import tkinter as tk class SampleApp(tk.Tk): def __init__(self): tk.Tk.__init__(self) self.entry = tk.Entry(self) self.button = tk.Button(self, text="Get", command=self.on_button) self.button.pack() self.entry.pack() def on_button(self): print(self.entry.get()) app = SampleApp() app.mainloop()
Run the program, type into the entry widget, then click on the button.