title: How can I reduce the code duplication on Tkinter to create grids and labels?
body: <p>I'm trying to create a user interface with Tkinter and there are a lot of labels and the command to create them it's very repetitive. I know in my guts there's a better more elegant way to do this but I don't know what it is :D</p>
  <p>Could you please advise me how you would reduce my 100+lines?</p>
  <pre><code>import tkinter as tk
  
  'create window'
  
  BLK_Window = tk.Tk()
  BLK_Window.title('Blackrock Primary Custom Baskets')
  BLK_Window.geometry('1280x720')
  BLK_Window.resizable(width=0, height=0)
  BLK_Window.columnconfigure(4,minsize=50)
  
  'set up min size for each column'
  
  BLK_Window.columnconfigure(5,minsize=50)
  BLK_Window.columnconfigure(6,minsize=50)
  BLK_Window.columnconfigure(7,minsize=50)
  BLK_Window.columnconfigure(8,minsize=50)
  BLK_Window.columnconfigure(9,minsize=50)
  BLK_Window.columnconfigure(10,minsize=50)
  BLK_Window.columnconfigure(11,minsize=50)
  BLK_Window.columnconfigure(12,minsize=50)
  BLK_Window.columnconfigure(13,minsize=50)
  BLK_Window.columnconfigure(14,minsize=50)
  BLK_Window.columnconfigure(15,minsize=50)
  BLK_Window.columnconfigure(16,minsize=50)
  BLK_Window.columnconfigure(17,minsize=50)
  BLK_Window.columnconfigure(18,minsize=50)
  BLK_Window.columnconfigure(19,minsize=50)
  
  'create every label'
  
  A_L1 = tk.Label(text=&quot;1)&quot;)
  A_L1.grid(row = 0, column = 0)
  
  A_L2 = tk.Label(text=&quot;Event Description&quot;)
  A_L2.grid(row = 0, column = 1)
  
  A_E1 = tk.Entry(BLK_Window)
  A_E1.grid(row = 0, column = 2)
  
  A_L3 = tk.Label(text=&quot;EV Score&quot;)
  A_L3.grid(row = 1, column = 1)
  
  A_E2 = tk.Entry(BLK_Window)
  A_E2.grid(row = 1, column = 2)
  
  A_L5 = tk.Label(text=&quot;Ticker&quot;,borderwidth=2, relief=&quot;groove&quot;)
  A_L5.grid(row = 0, column = 5,sticky=&quot;E&quot;+&quot;W&quot;)
  
  A_L6 = tk.Label(text=&quot;Shs&quot;,borderwidth=2, relief=&quot;groove&quot;)
  A_L6.grid(row = 0, column = 6,sticky=&quot;E&quot;+&quot;W&quot;)
  
  A_L7 = tk.Label(text=&quot;MV&quot;,borderwidth=2, relief=&quot;groove&quot;)
  A_L7.grid(row = 0, column = 7,sticky=&quot;E&quot;+&quot;W&quot;)
  
  A_L8 = tk.Label(text=&quot;Units&quot;,borderwidth=2, relief=&quot;groove&quot;)
  A_L8.grid(row = 0, column = 8,sticky=&quot;E&quot;+&quot;W&quot;)
  
  A_L9 = tk.Label(text=&quot;Cr/Re&quot;,borderwidth=2, relief=&quot;groove&quot;)
  A_L9.grid(row = 0, column = 9,sticky=&quot;E&quot;+&quot;W&quot;)
  
  A_L10 = tk.Label(text=&quot;AP/MM&quot;,borderwidth=2, relief=&quot;groove&quot;)
  A_L10.grid(row = 0, column = 10,sticky=&quot;E&quot;+&quot;W&quot;)
  
  A_L11 = tk.Label(text=&quot;Type&quot;,borderwidth=2, relief=&quot;groove&quot;)
  A_L11.grid(row = 0, column = 11,sticky=&quot;E&quot;+&quot;W&quot;)
  
  A_L12 = tk.Label(text=&quot;Feedback&quot;,borderwidth=2, relief=&quot;groove&quot;)
  A_L12.grid(row = 0, column = 12,sticky=&quot;E&quot;+&quot;W&quot;)
  
  A_L13 = tk.Label(text=&quot;OP Cutoff&quot;,borderwidth=2, relief=&quot;groove&quot;)
  A_L13.grid(row = 0, column = 13,sticky=&quot;E&quot;+&quot;W&quot;)
  
  A_L14 = tk.Label(text=&quot;LG Cutoff&quot;,borderwidth=2, relief=&quot;groove&quot;)
  A_L14.grid(row = 0, column = 14,sticky=&quot;E&quot;+&quot;W&quot;)
  
  A_L15 = tk.Label(text=&quot;BBG Ticker&quot;,borderwidth=2, relief=&quot;groove&quot;)
  A_L15.grid(row = 0, column = 15,sticky=&quot;E&quot;+&quot;W&quot;)
  
  A_L16= tk.Label(text=&quot;Market Cap&quot;,borderwidth=2, relief=&quot;groove&quot;)
  A_L16.grid(row = 0, column = 16,sticky=&quot;E&quot;+&quot;W&quot;)
  
  A_L17 = tk.Label(text=&quot;Fund AUM&quot;,borderwidth=2, relief=&quot;groove&quot;)
  A_L17.grid(row = 0, column = 17,sticky=&quot;E&quot;+&quot;W&quot;)
  
  A_L18 = tk.Label(text=&quot;Min&quot;,borderwidth=2, relief=&quot;groove&quot;)
  A_L18.grid(row = 0, column = 18,sticky=&quot;E&quot;+&quot;W&quot;)
  
  A_L19 = tk.Label(text=&quot;Max&quot;,borderwidth=2, relief=&quot;groove&quot;)
  A_L19.grid(row = 0, column = 19,sticky=&quot;E&quot;+&quot;W&quot;)
  
  A_O5 = tk.Label(master=BLK_Window)
  A_O5.grid(row = 1, column = 5)
  
  A_O6 = tk.Label(master=BLK_Window)
  A_O6.grid(row = 1, column = 6)
  
  A_O7 = tk.Label(master=BLK_Window)
  A_O7.grid(row = 1, column = 7)
  
  'function to sqr and apply to 3 cells'
  
  def sqr():
      x1 = A_E2.get()
      x2 = (float(x1))**2
      A_O5[&quot;text&quot;] = x2
      A_O6[&quot;text&quot;] = x2
      A_O7[&quot;text&quot;] = x2
      
  A_B2 = tk.Button(
      master=BLK_Window,
      text=&quot;Text&quot;,
      command=sqr
  )
  A_B2.grid(row = 1, column = 3,sticky=&quot;E&quot;+&quot;W&quot;)
  
  A_B1 = tk.Button(text =&quot;Check&quot;)
  A_B1.grid(row = 0, column = 3)
  
  BLK_Window.mainloop()
  </code></pre>
  <p>Thanks for your help</p>