forked from Techsrijan/mpsummer25
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtkinter_mouse_button_click.py
More file actions
32 lines (28 loc) · 930 Bytes
/
tkinter_mouse_button_click.py
File metadata and controls
32 lines (28 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from tkinter import *
root=Tk()
def left_click(event):
print("Left buton is clicked")
def middle_click(event):
print("middle buton is clicked")
def right_click(event):
print("right buton is clicked")
# creating a button
btn_left=Button(root,text="Left Click",fg="red",bg="yellow",
font=("Comic Sans Ms",15,"bold"))
btn_left.pack()
btn_right=Button(root,text="Right Click",fg="red",bg="yellow",
font=("Comic Sans Ms",15,"bold"))
btn_right.pack()
btn_middle=Button(root,text="Middle click",fg="red",bg="yellow",
font=("Comic Sans Ms",15,"bold"))
btn_middle.pack()
btn_left.bind("<Button-1>",left_click)
btn_middle.bind("<Button-2>",middle_click)
btn_right.bind("<Button-3>",right_click)
#for shortcutkey
root.bind("<Control-l>",left_click)
root.bind("<Control-m>",middle_click)
root.bind("<Control-r>",right_click)
root.geometry("400x500+200+100")
root.resizable(0,0)
root.mainloop()