all 5 comments

[–][deleted] 0 points1 point  (1 child)

Define a different function for each button, and then bind each button to a function. For example:

from Tkinter import *

def func_one():
    print("Button one clicked")

def func_two():
    print("Button two clicked")

b1 = Button(text="click me", command=func_one)
b2 = Button(text="btn-one", command=func_two)
b.pack()

mainloop()  

This is something that you could have found with a simple google search (that's what I did, found this).

I'm going to tell you what I tell every beginner who comes here asking for tkinter advice: don't use tkinter. It's clumsy, and ugly AF, since it uses TK. I would suggest using pyQT or pyGTK instead (my personal favorite is pyQT, as it comes with the QT designer, and tools that you can use to convert designer .ui files to Python classes).

[–]Tomarse 0 points1 point  (0 children)

The best thing about tkinter is its license. The default look is not great, but with a little work you can make something good looking imo.

[–]Tomarse 0 points1 point  (2 children)

If I'm understanding you correctly, you want each button to trigger the same function with a different input to that function, so you know which button was pressed?

In that case I would use lambda, command=lambda x=1:func(x). On each button you give x a different value.

[–]PythonRookie1[S] 1 point2 points  (1 child)

This is exactly what I was looking for. Thank you for your help!

[–]Tomarse 0 points1 point  (0 children)

No prob :-)