Title: Double clicking on an item in a listbox in tkinter and having that item show in search bar
Tags: python,tkinter

Question: This is my first time posting here so bare with me! I'm building an app that has a listbox of football player. What I'm trying to figure out is, I want to double click on an item in the listbox and I want it to show up in the search entry when clicked.
Here is my code. I've tried binding the button click and creating a new function to try and view the selected item in the search box. I've watched a few videos of trying to figure it out but they all do it without OOP, so maybe I'm putting these keybinds or functions in the wrong place. I just want to be able to double click an item in my listbox and have that name appear in the search bar.
import re
import tkinter as tk
from tkinter import ttk
from tkinter import *
from PIL import Image, ImageTk


root = tk.Tk()


class Player:
    """Creating the information for the soccer player"""
    def __init__(self,name,team,number):
        self.name = name
        self.team = team
        self.number = number




class Screen:

    def __init__(self,master):
        # Creating the main tkinter window
        self.master = master
        self.search_player()

    def search_player(self):
        """The main search window, this is where you will search for the player"""

        string1 = tk.StringVar()

        # Clears first frame
        for i in self.master.winfo_children():
            i.destroy()
        # Create first frame
        self.frame1 = tk.Frame(self.master, width=500, height=300)
        self.frame1.pack()
        # Search Label
        self.search_label = tk.Label(self.master, text="Search Player:", font=("Times, 12"))
        self.search_label.place(x=15, y=50)


        # Entry for searching
        self.search_entry = tk.Entry(self.master, font=("arial, 15"),textvariable=string1)
        self.search_entry.place(x=125, y=50)
        # Search Button
        self.search_button = tk.Button(self.master, text="Search", font=("Times, 13"), command=lambda: self.player_info_screen())
        self.search_button.place(x=360, y=47)

        # Listbox storing players name
        self.listbox1 = tk.Listbox(self.master,font=("Times, 12"))
        self.listbox1.place(x=125, y=100)

        # Scroll bar for list box
        self.scrollbar = tk.Scrollbar(self.master)
        self.scrollbar.place(x=310, y=100)

        # Attaching listbox to scrollbar and scrollbar to listbox
        self.listbox1.config(yscrollcommand=self.scrollbar.set)
        self.scrollbar.config(command=self.listbox1.yview())

        # list made up of each object instance showing players name
        footballer_names = [player1.name, player2.name, player3.name, player4.name]
        # Adding players into listbox
        for name in footballer_names:
            self.listbox1.insert(0, name)



player1 = Player("Neymar","Paris Saint Germain","10")


player2 = Player("Lionel Messi","Inter Miami","30")


player3 = Player("Kevin De Bruyne","Manchester City","17")

player4 = Player("Cristiano Ronaldo", "Al Nassr", "7")


window = Screen(root)



root.geometry("500x400")
root.mainloop()

Answer: You can set your text flag on the labels/ search field to return a function instead of a default string, so you can create a function that returns "Search Player" by default and then changes the return value to whatever player name it is when that player is double clicked