Im使用python2.7和PyQt4。我编写了一个简单的程序,在退出时使用QFileDialog.getExistingDirectory()
请求目录。然后它在QMessageBox
中显示,并询问用户是否要退出。完整代码是:
import sys
from PyQt4 import QtGui, QtCore
class Example(QtGui.QWidget):
def __init__(self):
super(Example, self).__init__()
self.initUI()
def initUI(self):
self.setGeometry(300, 300, 250, 150)
self.setWindowTitle('Message box')
self.show()
def closeEvent(self, event):
file = str(QtGui.QFileDialog.getExistingDirectory(self, "Select Directory"))
reply = QtGui.QMessageBox.question(self, 'Message',
file, QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
event.accept()
else:
event.ignore()
def main():
app = QtGui.QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
它的工作完美如预期-大小是好的,它可以调整大小。但是,当我使用PyInstaller编译代码时,文件夹对话框是全屏的,甚至不能调整大小。在
我怎样才能防止它发生?谢谢
编辑:
要创建等级库文件,我使用:
C:\Python\Python279\Scripts\pyi-makespec --icon=icon.ico --noconsole --name="Test" Test.py
要使用spec文件编译代码,我使用:
C:\Python\Python279\Scripts\pyi-build Test.spec
目前没有回答
相关问题 更多 >
编程相关推荐