title: Minesweeper in tkinter; why does this happen?
body: <p>I am trying to make minesweeper using buttons in tkinter, and it's my first time using tkinter. My only problem is that i don't know how to create buttons that react differently to different keys (i want 'f' to create a flag and left click to "open" the tile), whilst still being able to pass on a variable that is different from when the button was created to a function... Description will get clearer after code...</p>
  
  <pre><code>    from tkinter import *
      from random import *
      master = Tk()
      bomb_positions = []
  
      for i in range (160):
          random = randint(0, 2)
  
          if random == 0 or 1:                              #These are 'safe' buttons
              btn = Button(master, width=2)
              btn.bind('&lt;ButtonRelease-1&gt;', lambda event, i=i: check(i))
                                        #Correct value of i when check(i) is called at event
              btn.bind('f', lambda event, i=i: place_flag(i))
                                        #Diffrent value if i when place_flag(i) is called at event
              btn.pack()
              btn.grid(row=row, column=col)
  
          if random == 2:                              #These are 'bombs'
              btn = Button(master, width=2)
              btn.bind('&lt;ButtonRelease-1&gt;', function3)
              btn.bind('f', lambda event, i=i: place_flag(i))    #Same problem as above
              btn.pack()
              bomb_positions.append(i)
  </code></pre>
  
  <p>When running the program the specific value i for each button gets in to function1. However, when i press 'f' over any button the 'place_flag()' function is called, but the value of i is different. (Interestingly, the value of i that is used when the 'place_flag()' function is called starts off by not giving any value. For each press of TAB on an inactive part of the tkinter window, the value goes from 1 and increases with 1 for each press of Tab.) </p>
  
  <p>I want the value of i to be the same as the value that follows through to the 'check()' function, and I have no idea what causes my problem. Any ideas?</p>
  
  <p>(Very new to programming so sorry for incorrect terminology and fuzzy explanations... Happy for all the help I can get!) </p>