我有以下代码:
# -*- coding: utf-8-*-
import sys, convBB
from PyQt4 import QtGui, QtCore
class Window(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
layout = QtGui.QVBoxLayout(self)
self.resize(300,300)
self.setWindowTitle('Convert_BB_test')
self.setWindowIcon(QtGui.QIcon('icon.png'))
self.buttonSelect = QtGui.QPushButton('Select Files', self)
layout.addWidget(self.buttonSelect)
self.buttonSelect.clicked.connect(self.handleButton)
self.buttonConvert = QtGui.QPushButton('Convert', self)
layout.addWidget(self.buttonConvert)
self.buttonConvert.clicked.connect(self.convBB.convert(self.handleButton()))
def handleButton(self):
title = self.buttonSelect.text()
file_list = QtGui.QFileDialog.getOpenFileNames(self, title)
for path in file_list:
print (path)
#convBB.convert(list)
return file_list
#if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())
我从函数接收文件列表,handleButton
并希望在此列表中使用函数convBB.convert(list)
(来自 my ):convBB.py
self.buttonConvert.clicked.connect(self.convBB.convert(self.handleButton()))
并且有:
AttributeError: 'Window' object has no attribute 'convBB'
如何使用选择按钮选择文件,然后使用转换按钮进行转换?