Python Listbox Help.

Python Listbox Help.

Good day all.

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():



for i in a:


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



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


#Command to keep the window open


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Top Python Development Companies | Hire Python Developers

After analyzing clients and market requirements, TopDevelopers has come up with the list of the best Python service providers. These top-rated Python developers are widely appreciated for their professionalism in handling diverse projects. When...

Python GUI Programming Projects using Tkinter and Python 3

Python GUI Programming Projects using Tkinter and Python 3

Guide to Python Programming Language

Guide to Python Programming Language