Skip to content
Related Articles

Related Articles

Improve Article

Binding Function with double click with Tkinter ListBox

  • Difficulty Level : Basic
  • Last Updated : 21 Apr, 2020
Geek Week

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()
    # Updating label text to selected option
    # Setting Background Colour
    for list in cs:
        if list == 0:
        elif list == 1:
        elif list == 2:
        elif list == 3:
top = Tk()
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)
# Creating Edit box to show selected option
w = Label(top, text='Default')


 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :