Python2.7-pyqt4-eric6 讀取標準文字框內容,選擇資料夾並顯示絕對路徑
阿新 • • 發佈:2019-01-04
程式碼如下:
# -*- coding: utf-8 -*- """ Module implementing zhangcopy. """ import sys from PyQt4.QtCore import pyqtSignature from PyQt4.QtGui import QDialog, QFileDialog from PyQt4.QtGui import QApplication from Ui_zhangcopywindow import Ui_Dialog class zhangcopy(QDialog, Ui_Dialog): """ Class documentation goes here. """ text1='' text2='' text3='' path='' def __init__(self, parent=None): """ Constructor @param parent reference to the parent widget @type QWidget """ QDialog.__init__(self, parent) self.setupUi(self) @pyqtSignature("") def on_pushButton_1_clicked(self): """ Slot documentation goes here. """ # TODO: not implemented yet #raise NotImplementedError text1=self.lineEdit.text()#讀取text的內容 text2=self.lineEdit_2.text() self.label_4.setText(text1+text2) @pyqtSignature("QString") def on_lineEdit_textEdited(self, p0): """ Slot documentation goes here. @param p0 DESCRIPTION @type QString """ # TODO: not implemented yet # raise NotImplementedError @pyqtSignature("QString") def on_lineEdit_2_textEdited(self, p0): """ Slot documentation goes here. @param p0 DESCRIPTION @type QString """ # TODO: not implemented yet # raise NotImplementedError @pyqtSignature("QString") def on_lineEdit_3_textEdited(self, p0): """ Slot documentation goes here. """ # TODO: not implemented yet #raise NotImplementedError @pyqtSignature("") def on_pushButton_3_clicked(self): """ Slot documentation goes here. """ # TODO: not implemented yet # raise NotImplementedError open=QFileDialog() path=open.getExistingDirectory(self, "choose directory", "G:\\")#專門的函式 print path strpath=unicode(path.toUtf8(), 'utf-8', 'ignore') self.lineEdit_3.setText(strpath) if __name__ == '__main__': app = QApplication(sys.argv) dlg = zhangcopy() dlg.show() #之前少加了一個括號 sys.exit(app.exec_())