title: tkinter - how to make separate hyperlink button in my loop?
body: <p>I'm trying to make some simple program to open url if the condition fits.</p>
  <p>Here's the minimal reproducible example.</p>
  <pre><code>from tkinter import *
  import requests
  from bs4 import BeautifulSoup
  import webbrowser
  import time
  
  def call_back(event):
      input_id.delete(0,END)
      return None
  
  def open_browse(url):
      webbrowser.open_new(url)
  
  
  
  win = Tk()
  win.geometry(&quot;150x150&quot;)
  win.title(&quot;Example&quot;)
  
  search_btn = Button(win)
  search_btn.config(text=&quot;search&quot;)
  search_btn.config(width=5,height=1)
  search_btn.grid(column = 2, row = 2)
  
  
  def search_chr():
      
      chr_list = [&quot;test1&quot;,&quot;test2&quot;]
      result = [(0,&quot;test_r_1&quot;),(0,&quot;test_r_2&quot;)]
      var_dict = {}
      num = -1
      for ch in chr_list:
          num += 1
          var_dict[&quot;output%s&quot; %num] = Entry(win, width = 10)
          
          
          if result[0] == 0:
              pass
          else:
              link_url = result[num][1]
              print(link_url)
              var_dict[&quot;o-button%s&quot; %num] = Button(win, command=lambda aurl=link_url:open_browse(link_url))
              var_dict[&quot;output&quot;+str(num)].insert(0, &quot;Text&quot;)
              var_dict[&quot;output&quot;+str(num)].grid(column = 0, row = 0+num, columnspan = 4, sticky=W, padx=5, pady=5)
              var_dict[&quot;o-button&quot;+str(num)].config(text=&quot;URL&quot;)
              
              var_dict[&quot;o-button&quot;+str(num)].grid(column = 4, row = 0+num, sticky=E, padx=5, pady=5)
              var_dict[&quot;output&quot;+str(num)].config(state=&quot;disabled&quot;)
  
  search_btn.config(command = search_chr)
  
  
  win.mainloop()
  </code></pre>
  <p>So, if you run the code, there would be a button.
  And if you click it, There will be two sets of Label with &quot;Text&quot; in it and Button with &quot;URL&quot; in it. When you press the URL button, it should open a browse with a given url.</p>
  <p>As you see the printed text in your terminal, the url is supposed to be &quot;test_r_1&quot; and &quot;test_r_2&quot;
  But, if you press each button, all buttons are directed to &quot;test_r_2&quot;.
  It seems that it somehow overwrote the previous &quot;test_r_1&quot; as well.</p>
  <p>If anyone can explain how to make each button to link to each url, it would be perfect.
  Thanks for stopping by, and I hope you can help me with this.</p>