File tree 3 files changed +29
-0
lines changed
GUIScripts/Event Handling
3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change
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 number Diff line number Diff line change
1
+ from tkinter import *
You can’t perform that action at this time.
0 commit comments