title: Python: Using Tkinter radio-buttons to add/remove fields from GUI
body: <p>I'm currently working on a GUI-based (Tkinter) project used to reduce matrices, just for practice. 
  Before I dive into the actual math stuff, I'm working on a basic window to ask the user for information to format their matrix.</p>
  
  <p>In one field, I have radio-buttons - one is "Fraction", the other is "Decimal" - they can choose either for their output format. What I want is, if the user chooses "Decimal", another Entry field will appear below so that they can enter the number of decimals to round to, and if they choose "Fraction", the field won't appear.</p>
  
  <p>I've searched around a bit on Stack Overflow, and saw a bit about using "raise()" and "lower()" methods, but it's not working right now. If you guys can give any input, that would be great. General feedback about the GUI is also appreciated - I learned GUIs in Python in school a while back, so if the format is bad, let me know!</p>
  
  <p>Thanks in advance!</p>
  
  <p>Edit: I'm running Python 3.4.</p>
  
  <pre><code>import tkinter
  
  class Reducer:
  '''
  Takes user input of a matrix and row-reduces it to RREF.
  
  GUI-Based interface that asks the user for the # of rows and columns, as well as output formatting.
  The program can output as a fraction or a decimal with a specified number of decimals.
  '''
  
  
  def __init__(self):
      '''
      Initializes the GUI interface that asks the user for input.
  
      No parameters or returns.
      '''
  
      self.main_window = tkinter.Tk()
  
      #Initalize frames.
      self.info_frame = tkinter.Frame()
      self.size_frame = tkinter.Frame()
      self.format_frame = tkinter.Frame()
      self.digit_frame = tkinter.Frame()
      self.button_frame = tkinter.Frame()
  
      #Object for the information frame.
      self.info_label = tkinter.Label(self.info_frame, text="Enter the number of rows and columns, your preferred output format,"
                                             " and the number of trailing decimals if applicable.", justify="left",
                                      wraplength=275).pack()
  
      #Objects for the size frame - the matrix's rows/columns are set here.
      self.row_label = tkinter.Label(self.size_frame, text="Rows:").pack(side="left")
      self.row = tkinter.Entry(self.size_frame, width=3).pack(side="left")
      self.col_label = tkinter.Label(self.size_frame, text="Columns:").pack(side="left")
      self.col = tkinter.Entry(self.size_frame, width=3).pack(side="left")
  
      #Objects for the digit frame
      self.digit_label = tkinter.Label(self.digit_frame, text="Digits:")
      self.digit = tkinter.Entry(self.digit_frame, width=3)
      self.digit_label.pack(side="left")
      self.digit.pack(side="left")
  
      #Objects for the format frame - the output formatting is specified here.
      self.output_var = tkinter.IntVar()
      self.output_var.set(0)
  
      self.fraction = tkinter.Radiobutton(self.format_frame, text="Fraction", variable=self.output_var, value=0,
                                          command=self.hide_digits()).pack(side="left")
  
      self.decimal = tkinter.Radiobutton(self.format_frame, text="Decimal", variable=self.output_var, value=1,
                                         command=self.show_digits()).pack(side="left")
  
      #Object for the bottom frame
  
      self.button = tkinter.Button(self.button_frame, text="Next", command=self.reduce).pack()
  
      #Pack frames.
      self.info_frame.pack(anchor="nw")
      self.size_frame.pack(anchor="nw")
      self.format_frame.pack(anchor="nw")
      self.digit_frame.pack(anchor="nw")
      self.button_frame.pack(anchor="nw")
  
      tkinter.mainloop()
  
  def show_digits(self):
      self.digit_label.lift(self.col)
      self.digit.lift(self.col)
  
  def hide_digits(self):
      self.digit_label.lower(self.col)
      self.digit.lower(self.col)
  
  def reduce(self):
      pass
  
  
  
  reducer = Reducer()
  </code></pre>