I'm creating BattleShip in Python 3.4.1 and I'm using Tkinter.
This is my source code:
from tkinter import *
vText = ["A","B","C","D","E","F","G","H","I","J"]
def press(a,b):
print("You pressed: " + str(a * 10 + b))
root = Tk()
def button():
for i in range(0,10):
global self
for j in range(1,11):
self = Button(root, text = vText[i] + str(j), command = lambda: press(i,j), padx = 20, pady = 20).grid(row = i, column = j)
root.wm_title("Enemy grid")
button()
root.mainloop()
Later I want to do a function based on what button is pressed. How do I do that?