title: Tkinter GUI without repeating code
body: <p>been struggling a while with the finishing touches of my program. I figured someone might be able to help out.</p>
  
  <p>Basically, my program consists asks the user which out of 4 companies it wants to display information about, using 4 buttons.</p>
  
  <pre><code>class CompanyAnalysis(tk.Frame):
  
      def displayfunction(controller, j):
          return lambda: controller.show_frame(j)
  
      company_choice = ["AnalysisCompany1", "AnalysisCompany2", "AnalysisCompany3", "AnalysisCompany4"]
      company_name = ["Company1", "Company2", "Company3", "Company4"]
  
      def __init__(self, parent, controller):
          tk.Frame.__init__(self, parent)
          self.controller = controller
  
          header = tk.Label(self, text="Which company to analyze?")
          header.pack(side="top", padx=2, pady=2, fill="x")
  
          for i,j in zip(company_name, company_choice):
              button = tk.Button(self, text=i, command=displayfunction(controller,j))
              knapp.pack(side="top", padx=2, pady=2, fill="x")
  </code></pre>
  
  <p>That is basically the class for my company choices. However, my GUI being built the way it is, i currently have 4 IDENTICAL classes for the frames displaying company information. They look as follows:</p>
  
  <pre><code>class FAnalysEricsson(tk.Frame):
  
  
  def __init__(self, parent, controller):
      tk.Frame.__init__(self, parent)
      self.controller = controller
  
      text = tk.Message(self, text=companylist[0].fundamental())
      text.pack(side="top", padx=2, pady=2, fill="x")
  </code></pre>
  
  <p>Where companylist is a list of objects, where i call the method fundamental which returns the information about the company. How do i design my GUI without repeating my code for each company? I was thinking maybe a toplevel window, like some sort of function (instead of the displayfunction) which when i press a button opens a new window displaying the information for the correct company (index of the companylist). </p>
  
  <p>Please do not hesitate to ask me to clarify anything, kind of hard to explain without posting the entirety of my code.</p>