Display directory pyqt4 and Python

Dunwitch dunwitch at gmail.com
Wed Apr 1 22:30:28 EDT 2009


I've looked around for the answer and have decided to ask an expert
for the solution. Whats suppose to happen is a user pushes a button
and displays the directory content in the text edit window on the gui.
Everything works, apart from the fact that it only shows the last file
in the directory, not a full listing. Here is the code for reference.
Any help would be appreciated, I'm missing something simple.
--
Dunwitch

# File : Video Search
import sys, os, win32net

from PyQt4 import QtGui, QtCore
from findVideos import Ui_MainWindow # UI Files from QT Designer

# New class derived from QMainWindow
class TestApp(QtGui.QMainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # Connect the signals andslots
        QtCore.QObject.connect(self.ui.findFiles,QtCore.SIGNAL("clicked
()"), self.showVideoFiles)

#----------------------------- Code In Question
---------------------------------
    def showVideoFiles(self):
        enc7 = ('\\\\1.2.3.4\\somefolder')
        fileList=os.listdir(enc7)
        for x in (fileList):
            self.ui.displayVideo.setText(x) # This only shows the last
file in the directory?
#-------------------------------------------------------------------------------------------

if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    window = TestApp()
    window.show()
    sys.exit(app.exec_())



More information about the Python-list mailing list