Prerequisites: Python GUI – tkinter, Python | Binding function in Tkinter
Tkinter in Python is GUI (Graphical User Interface) module which is widely used for creating desktop applications. It provides various basic widgets to build a GUI program.
To bind Double click with Listbox we use Binding functions in Python and then we execute the required actions based on the item selected in Listbox.
Below is the implementation:
from tkinter import *
def go(event):
cs = Lb.curselection()
w.config(text = Lb.get(cs))
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' )
Lb = Listbox(top, height = 6 )
Lb.insert( 0 , 'Red' )
Lb.insert( 1 , 'Green' )
Lb.insert( 2 , 'Yellow' )
Lb.insert( 3 , 'White' )
Lb.bind( '<Double-1>' , go)
Lb.pack()
w = Label(top, text = 'Default' )
w.pack()
top.mainloop()
|
Output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
21 Apr, 2020
Like Article
Save Article