title: Tkinter Button either click or Press Return
body: <p><strong>Brief description of the application:</strong></p>
  
  <p>I have created an application form that is attempting to capture a "X" quantity  of serial numbers and the Serial Number itself. If user enter a valid quantity, I enable the "Save SN" button. </p>
  
  <p><strong>The problem:</strong></p>
  
  <p>The problem I have, is that form is able to capture up to 120 SN's. so capturing the SN and clicking "Save SN" each time is getting annoying. </p>
  
  <p><strong>The question:</strong></p>
  
  <p>How to either, click the button to execute the <code>def</code> or Press "Return" (Enter) on the computer to execute the function? </p>
  
  <p>** <code>def enter(self)</code> -- > To get the user input, validate and Save a valid quantity</p>
  
  <p>** <code>def validatesn(self)</code> -- > To get the user input and validate the Serial Number format.</p>
  
  <p>Please see below my code: </p>
  
  <pre><code>from tkinter import *
  from tkinter import messagebox
  
  sn_count = 0
  class SerialForm ():
      def enter(self):
          global oven_qty
          oven_qty = self.qty.get()
          print(oven_qty)
  
      def validatesn(self):
          global sn_count, oven_qty
          new_sn = self.serial.get()
          print(new_sn)
          print (sn_count)
  
      def __init__(self, window):
          self.window = window
          window.geometry('390x320+400+200')
          window.resizable(False,False)
          window.title("App 1.30")
          LabelFrame(window, text = "  Serial Number Entry Form  : ", font = ("Tahoma",14), height=250, width=360, bd=2, relief='groove' ).place(x=15,y=0)
          Label(text='Quantity  :',font=("Tahoma", 12)).place(x=20,y=40)
          Label(text='Quantity Count   :',font=("Tahoma", 12)).place(x=20,y=80)
          LabelFrame(window, font = ("Tahoma",12), height=28, width = 145, bd=2, relief='ridge' ).place(x=160,y=80)
          Label(text='Serial N.  :',font=("Tahoma", 12)).place(x=20,y=120)
          self.qty = Entry(window, font=("Arial Narrow", 12))
          self.qty.place(x=160,y=40)
          self.qty.config(state = NORMAL)
          self.serial = Entry(window, font=("Arial Narrow", 12))
          self.serial.place(x=160,y=120)
          self.serial.config(state = DISABLED)
          Label(text='Last Serial N.      :',font=("Tahoma", 12)).place(x=20,y=160)
          LabelFrame(window, font = ("Tahoma",12), height=28, width = 145, bd=2, relief='ridge' ).place(x=160,y=160)
          self.window_btne = Button(window, text=" Enter Qty ", font=("Tahoma", 14), height=1, width=10, command=self.enter)
          self.window_btne.place(x = 20, y = 200)
          self.window_btne.config(state = NORMAL)
          self.window_btns = Button(window, text=" Save SN ", font=("Tahoma", 14), height=1, width=10, command = self.validatesn)
          self.window_btns.place(x = 140, y = 200)
          self.window_btns.config(state = DISABLED)
  
  root = Tk()
  my_gui = SerialForm(root)
  root.mainloop()
  </code></pre>