Python Listbox Help.

Good day all.

I am new to programming period. I have chosen Python as my first language. I have given myself a few projects. I am stuck with one.

I have created a GUI(tkinter) and I am using Listbox. I am able to os.chdir(Change Directory) so I can view the files that are in a folder on my machine. However, I am not able to pull up any of the files. Whenever I click on a file, the name of the file shows up in my terminal. I want the file i.e. pdf, docx, etc... to be displayed.

Anybody have any ideas as to how I can make this happen?

Variables and their attributes I am creating for this Application

listbox = Listbox(root, width=50, height=20, relief=RAISED, bg='yellow', font=('times', 12), yscrollcommand=scrollbar.set)

for name in os.listdir(os.chdir('C:\\Users\Broth_000\\Desktop\\PC\\')):

listbox.insert('end', name)



#Definitions I am creating for this Application

def pSelection():


a=listbox.curselection()

print(a)

for i in a:

print(listbox.get(ANCHOR))


def OnDouble(event):

w = event.widget

idx = int(w.curselection()[0])

value = w.get(idx)

print(0, value)

#Buttons I will be using for this Application and their attributes

btn1 = Button(bottomFrame, text="Print", width=40, relief=RAISED, bd=8, fg="blue", command=pSelection)

btn2 = Button(bottomFrame, text="Print2", width=40, relief=RAISED, bd=8, fg="blue", command=OnDouble)

btn2.bind(root, "<Button-1>", partial(OnDouble, name=name))


#Where I am placing buttons for this Application

btn1.pack()

btn2.pack()

listbox.bind('<<ListboxSelect>>', OnDouble)

listbox.pack(side=BOTTOM)



#Command to keep the window open

root.mainloop()

#python

2.05 GEEK