[英]pyqt4 QtGui.QFileDialog.getSaveFileName clicke cancel Button
I'm using PyQt4. 我正在使用PyQt4。
filename = QtGui.QFileDialog.getSaveFileName(self, "Save file", "", "CSV files (*.csv)|*.csv")
Now when I click cancel button,the next code is executing. 现在,当我点击取消按钮,下一个代码执行。 But, I don't want this instead I want it to do nothing.
但是,我不希望这样做,而是希望它什么也不做。 How can I achieve this?
我该如何实现?
If filename is None:
stop excute code.
If the user presses Cancel, getSaveFileName
returns a null string. 如果用户按“取消”,则
getSaveFileName
返回一个空字符串。
You can use the fact that empty sequences are false. 您可以使用空序列为假的事实。 So, you should use:
因此,您应该使用:
if filename:
or 要么
if not filename:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.