嘿傢伙我想使用我的函數在另一個窗口中的一個類的函數中獲取的目錄。我想將選擇的目錄傳遞給彈出窗口,以便顯示所有文件。任何幫助將apprciatedPYQT將功能從一個類傳遞到另一個窗口
class createedditConvertorpage(QtGui.QMainWindow):
def __init__(self,parent = None):
QtGui.QWidget.__init__(self, parent)
def selectFilecsvtoxml(self):
directory = QtGui.QFileDialog.getExistingDirectory(self, "Pick a folder")
print directory
self.listDirPath.setText(directory)
for file_name in os.listdir(directory):
if not file_name.startswith("."):
print (file_name) + " this is selectFilcestoxml"
self.directory = directory
return directory
class readoutWindow(QtGui.QDialog):
def openTxt(self):
directoryFile = createedditConvertorpage()
directoryFile.selectFilecsvtoxml()
print "this s open text"
print str(directoryFile)
for file_name in directoryFile:
if file_name.endswith(".txt"):
print (file_name) + " this is txt file"
File "/home/ed/Development/Python/Workmain/windows.py", line 1425, in home
self.openTxt()
File "/home/ed/Development/Python/Workmain/windows.py", line 1442, in openTxt
for file_name in directoryFile:
TypeError: 'createedditConvertorpage' object is not iterable
你的回答很近,給你信用 – Anekdotin