版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_36602742/article/details/78917164
代码如下:
# -*- 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_())