forked from Techsrijan/summer2025
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtkinter_mouse_button.py
More file actions
38 lines (31 loc) · 957 Bytes
/
tkinter_mouse_button.py
File metadata and controls
38 lines (31 loc) · 957 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
33
34
35
36
37
38
from tkinter import *
def left_click(event):
print("left button is clciked")
def middle_click(event):
print("middle button is clciked")
def right_click(event):
print("right button is clciked")
root=Tk()
root.title("My first window")
btn=Button(root,text="Left click", fg="red",bg="yellow",
font=("comic sans ms",25,'bold'),
)
btn.pack()
btn1=Button(root,text="Middle Click", fg="red",bg="yellow",
font=("comic sans ms",25,'bold'),
)
btn1.pack()
btn12=Button(root,text="Right Click", fg="red",bg="yellow",
font=("comic sans ms",25,'bold'),
)
btn12.pack()
btn.bind("<Button-1>",left_click)
btn12.bind("<Button-3>",right_click)
btn1.bind("<Button-2>",middle_click)
root.bind("<Control-l>",left_click)
root.bind("<Control-r>",right_click)
root.bind("<Control-m>",middle_click)
root.geometry("400x400+500+200")
root.resizable(0,0)
root.wm_iconbitmap('cal.ico')
root.mainloop()