title: How do you align labels and entry boxes in a GUI program?
body: <p>I am trying to create a simple GUI program with Python, but I am having trouble aligning the labels of my program so that the first letter of each word lines up with one another. I tried to use <code>anchor="nw"</code> and <code>anchor="w"</code>, but these did not seem to do the trick. I am also having a hard time getting the entry boxes to align with each other. My code as well as the expected GUI are attached. If anyone has suggestions, please let me know. </p>
  
  <pre><code>import tkinter
  
  class Loan:
      def __init__(self):
          #Create main Window
          self.main_window = tkinter.Tk()
          self.main_window.title("Loan Calculator")
  
          #Create the six frames
          self.intRate_frame = tkinter.Frame(self.main_window)
          self.numYears_frame = tkinter.Frame(self.main_window)
          self.loanAmount_frame = tkinter.Frame(self.main_window)
          self.monthlyPayment_frame = tkinter.Frame(self.main_window)
          self.totalPayment_frame = tkinter.Frame(self.main_window)
          self.button_frame = tkinter.Frame(self.main_window)
  
          # Create and pack the widgets for interest rate
          self.intRate_label = tkinter.Label(self.intRate_frame, \
                  text='Annual Interest Rate', anchor="w")
          self.intRate_entry = tkinter.Entry(self.intRate_frame, \
                                   width=20)
          self.intRate_label.pack(side='left')
          self.intRate_entry.pack(side='left')
  
          #Create and pack the widgets for number of years
          self.numYears_label = tkinter.Label(self.numYears_frame, \
                  text='Number of Years', anchor = "w")
          self.numYears_entry = tkinter.Entry(self.numYears_frame, \
                                   width=20)
          self.numYears_label.pack(side='left')
          self.numYears_entry.pack(side='left')
  
  
          #Create and pack the widgets for loan Amount
          self.loanAmount_label = tkinter.Label(self.loanAmount_frame, \
                  text='Loan Amount', anchor = "nw")
          self.loanAmount_entry = tkinter.Entry(self.loanAmount_frame, \
                                   width=20)
          self.loanAmount_label.pack(side='left')
          self.loanAmount_entry.pack(side='left')
  
          #Create and pack the widgets for monthly payment
          self.result_label = tkinter.Label(self.monthlyPayment_frame, \
                  text='Monthly Payment', anchor="w")
          self.monthlyPayment = tkinter.StringVar() # To update avg_label
          self.monthlyPayment_label = tkinter.Label(self.monthlyPayment_frame, \
                              textvariable=self.monthlyPayment)
          self.result_label.pack(side='left')
          self.monthlyPayment_label.pack(side='left')
  
          #Create and pack the widgets for total payment
          self.result2_label = tkinter.Label(self.totalPayment_frame, \
                  text='Total Payment', anchor="w")
          self.totalPayment = tkinter.StringVar() # To update avg_label
          self.totalPayment_label = tkinter.Label(self.totalPayment_frame, \
                              textvariable=self.totalPayment)
          self.result2_label.pack(side='left')
          self.totalPayment_label.pack(side='left')
  
          #Create and pack the widgets for the button widgets
          self.compute_button = tkinter.Button(self.button_frame, \
                               text='Compute Payment', command=self.calc)
          self.compute_button.pack(side='left')
  
          self.intRate_frame.pack()
          self.numYears_frame.pack()
          self.loanAmount_frame.pack()
          self.monthlyPayment_frame.pack()
          self.totalPayment_frame.pack()
          self.button_frame.pack()
  
          tkinter.mainloop()
  
      def calc(self):
          #Get 
          self.intRate = float(self.intRate_entry.get())
          self.numYears = float(self.numYears_entry.get())
          self.loanAmount = float(self.loanAmount_entry.get())
          #Calculations
          monthlyIntRate = self.intRate / 1200   
          monthlyPayment = self.loanAmount * monthlyIntRate/(1 - (1 / (1 +     [enter image description here][1]monthlyIntRate) ** (self.numYears * 12))) 
          totalPayment = self.monthlyPayment * self.numYears * 12 #calculates the total payment
  
          self.monthlyPayment.set(self.monthlyPayment)
          self.totalPayment.set(self.totalPayment)
  
  
  loan1 = Loan()
  </code></pre>
  
  <p>Expected GUI:</p>
  
  <p><img src="https://i.stack.imgur.com/KCSvP.png" width="262" height="145"></p>