以前用delphi 有onclick 事件。
建议研究一下下面的代码
from Tkinter import *
root = Tk()
def key(event):
print "pressed", repr(event.char)
def callback(event):
print "clicked at", event.x, event.y
canvas= Canvas(root, width=100, height=100)
canvas.bind("", key)
canvas.bind("", callback)
canvas.pack()
root.mainloop()Events and Bindingseffbot.org
和
import Tkinter
import tkMessageBox
top = Tkinter.Tk()
def helloCallBack():
tkMessageBox.showinfo( "Hello Python", "Hello World")
B = Tkinter.Button(top, text ="Hello", command = helloCallBack)
B.pack()
top.mainloop()Python - Tkinter Buttonwww.tutorialspoint.com