最常用的Button类型有哪些操作事件呢呢?
- 鼠标左、中、右键,按下;
- 鼠标左、中、右键,释放;
- 鼠标左、中、右键,按着路过;
- 鼠标离开;
import tkinter
window = tkinter.Tk()
window.title("GUI")
b = tkinter.Button(window, text = "Button") # this is placed in 1 0
b.pack()
#creating 3 different functions for 3 events
def left_click(event):
tkinter.Label(window, text = "Left Click!").pack()
def left_released(event):
tkinter.Label(window, text = "Left Released!").pack()
def left_Motion(event):
tkinter.Label(window, text = "Left Motion!").pack()
def left_doubleclick(event):
tkinter.Label(window, text = "Left Double Click!").pack()
def left_Motion(event):
tkinter.Label(window, text = "Left Move!").pack()
def middle_click(event):
tkinter.Label(window, text = "Middle Click!").pack()
def right_click(event):
tkinter.Label(window, text = "Right Click!").pack()
b.bind("<Button-1>", left_click)
b.bind("<B1-Motion>", left