text: import tkinter as tk
  
  class Application(tk.Frame):
      def __init__(self, master = None):
          super().__init__(master)
          self.pack()
          self.create_widgets()
          
      def create_widgets(self):
          self.hi_there = tk.Button(self)
          self.hi_there["text"] = "Hello World \n (click me)"
          self.hi_there["command"] = self.say_hi
          self.hi_there.pack(side="top")
          
          self.quit = tk.Button(self, text="QUIT", fg="red", 
                                command= root.destroy)
          self.quit.pack(side = "bottom")
          
      def say_hi(self):
          print("hi there, everyone!")
  root= tk.Tk()
  app = Application(master=root)
  app.mainloop()
  
  
  
  class App(tk.Frame):
      def __init__(self, master=None):
          super().__init__(master)
          self.pack()
  
          self.entrythingy = tk.Entry()
          self.entrythingy.pack()
  
          # here is the application variable
          self.contents = tk.StringVar()
          # set it to some value
          self.contents.tk.set("this is a variable")
          # tell the entry widget to watch this variable
          self.entrythingy["textvariable"] = self.tk.contents
  
          # and here we get a callback when the user hits return.
          # we will have the program print out the value of the
          # application variable when the user hits return
          self.entrythingy.bind('<Key-Return>',
                                self.print_contents)
  
      def print_contents(self, event):
          print("hi. contents of entry is now ---->",
                self.contents.get())