[PyQt] Populating a listWidget with a list of files

jaybstory jaybstory at yahoo.com
Thu Mar 4 02:34:11 GMT 2010


I wanted to know how to have a list widget contain a list of files. 
Basically, I want to be able to give a path to a list of video files and
have the video file names displayed in a list widget.  Then I want the user
be able to click a file which will open an external program.

I can already have the user click a button which opens files using
QFileDialog.  Then they can select a file which then opens VLC (I did this
by using QProcess).  

Here is my code which can do what I mentioned above:

#code for signal slot connection between the button and the def video

 def video(self):
                fd2 = QtGui.QFileDialog(self)
		self.filename = fd2.getOpenFileName()
		from os.path import isfile
		if isfile(self.filename):
			import codecs
			s = codecs.open(self.filename,'r').read()
                        #z = self.filename
                       # print z
                video = QtCore.QProcess(self)
                a = "vlc "+z

I now want to know how to place the list of files into a list Widget.  Thank
you in advance.
View this message in context: http://old.nabble.com/Populating-a-listWidget-with-a-list-of-files-tp27776406p27776406.html
Sent from the PyQt mailing list archive at Nabble.com.

More information about the PyQt mailing list