-
Notifications
You must be signed in to change notification settings - Fork 0
/
double_click_5.py
43 lines (33 loc) · 917 Bytes
/
double_click_5.py
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
39
40
41
42
43
from tkinter import *
def go(event):
cs = Lb.curselection()
# Updating label text to selected option
w.config(text=Lb.get(Lb.curselection()))
# Setting Background Colour
for list in cs:
if list == 0:
top.configure(background='red')
elif list == 1:
top.configure(background='green')
elif list == 2:
top.configure(background='yellow')
elif list == 3:
top.configure(background='white')
top = Tk()
top.geometry('250x275')
top.title('Double Click')
# Creating Listbox
Lb = Listbox(top, height=6)
# Inserting items in Listbox
Lb.insert(0, 'Red')
Lb.insert(1, 'Green')
Lb.insert(2, 'Yellow')
Lb.insert(3, 'White')
# Binding double click with left mouse
# button with go function
Lb.bind('<Double-1>', go)
Lb.pack()
# Creating Edit box to show selected option
w = Label(top, text='Default')
w.pack()
top.mainloop()