Skip to content

Commit 444d15b

Browse files
authored
Add files via upload
1 parent 434e492 commit 444d15b

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
13.7 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# importing tkinter
2+
from tkinter import *
3+
# initializing root
4+
root = Tk()
5+
# width and height variables
6+
can_width = 300
7+
can_height = 200
8+
# setting geometry of gui
9+
root.geometry(f"{can_width}x{can_height}")
10+
# setting title of gui
11+
root.title("Event handling")
12+
# creating a label
13+
Label(root, text="Click anywhere").pack()
14+
# initializing variable
15+
i = 0
16+
# defining a function
17+
def me(event):
18+
global i
19+
Label(root, text=f"You clicked me {i} time").pack()
20+
Label(root, text="Double click to exit screen").pack()
21+
i=i+1
22+
# binding mouse left button to root and calling me function
23+
root.bind("<Button-1>", me)
24+
# binding double click mouse left button to root and calling
25+
# in-built quit function
26+
root.bind("<Double-1>", quit)
27+
# calling mainloop
28+
root.mainloop()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from tkinter import *

0 commit comments

Comments
 (0)