Display directory pyqt4 and Python
Diez B. Roggisch
deets at nospam.web.de
Thu Apr 2 03:02:06 EDT 2009
Dunwitch schrieb:
> 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?
Of course, if you always only set the *full* text of the displayVideo to
the current list-item, it will end showing the last set item.
self.ui.displayVideo("\n".join(fileList))
should do the trick (of course you can get rid of the for-loop)
Diez
More information about the Python-list
mailing list