AttributeError:' ExampleApp'对象没有属性' browse_folder'

时间:2017-03-06 07:37:28

标签: python pyqt pyqt4

from PyQt4 import QtGui
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
import ADJ_Search
import os

from selenium import webdriver
from selenium.webdriver.support.ui import Select
import webbrowser
class ExampleApp(QtGui.QMainWindow, ADJ_Search.Ui_MainWindow):
    def __init__(self):
        super(self.__class__, self).__init__()
        self.setupUi(self)
        self.Chose_File_Button.clicked.connect(self.browse_folder)
        self.List_Search_Button.clicked.connect(self.search_list)

    def browse_folder(self):
        self.List_ADJ_View.clear()
        dlg = QFileDialog()
        dlg.setFileMode(QFileDialog.AnyFile)
        directory = QStringList()
        if dlg.exec_():
            directory = dlg.selectedFiles()
            f = open(directory[0], 'r')         
            with f:
                data = f.readlines()
                for ADJ in data:
                    self.List_ADJ_View.addItem(ADJ.strip())
                    print ADJ.strip()

    def search_list(self):
        self.List_ADJ_View.clear()
        print ''

def main():
        app = QtGui.QApplication(sys.argv)
        form = ExampleApp()
        form.show()
        app.exec_()

if __name__=='__main__':
        main()

错误:

Error:Traceback (most recent call last):
      File "temperary.py", line 45, in <module>
      File "temperary.py", line 40, in main
      form = ExampleApp()
      File "temperary.py", line 15, in __init__
      self.Chose_File_Button.clicked.connect(self.browse_folder)
      AttributeError: 'ExampleApp' object has no attribute 'browse_folder'

请帮助我了解为什么它总会出现此错误,也是&#39; search_list&#39;也有这种错误。您认为是什么导致了它?

0 个答案:

没有答案