标签:
网址可以参见:http://permalink.gmane.org/gmane.comp.python.chinese/9916
处理方式的代码可以参考如下
#[1]第一种写法 filePath = unicode(QtGui.QFileDialog.getOpenFileName(None, "All Files (*)", self)) #[2]第二种写法 filechoose = QtGui.QFileDialog(self) filePath = unicode(filechoose.getOpenFileName())
网址可以参考:http://bbs.csdn.net/topics/390948296
上面的网址帖子没人回
下面的帖子不是PyQt4,是C#,但是我发现问题是一样的
http://bbs.csdn.net/topics/380009233
即在如下代码区区域多写了一个定义声明,造成对话框打开两次
#伪代码 class Function(): def __init__(): QWidget.__init__(self, parent) self.setupUi(self) QtCore.QObject.connect(self.读取文件的对话框按钮对象,QtCore.SIGNAL("clicked()"), self.读取文件的对话框按钮对象的点击触发操作) #请注意,上面这句话导致对话框打开两次,所以注释掉本句即可,就会变成正常的对话框打开一次 def 读取文件的对话框按钮对象的点击触发操作(self): filechoose = QtGui.QFileDialog(self) filepath_meta_of_tab = unicode(filechoose.getOpenFileName()) content_meta_of_tab = open(filepath_meta_of_tab).read() self.M1_InputPath.setText( filepath_meta_of_tab )
标签:
原文地址:http://www.cnblogs.com/bitpeach/p/4442771.html