Python PyQt文件夹对话框编译后更改大小
我正在使用Python2.7和PyQt4。我编写了一个简单的程序,在退出时使用Python PyQt文件夹对话框编译后更改大小,python,dialog,pyqt,pyinstaller,Python,Dialog,Pyqt,Pyinstaller,我正在使用Python2.7和PyQt4。我编写了一个简单的程序,在退出时使用QFileDialog.getExistingDirectory()请求目录。然后它在QMessageBox中显示它,并询问用户是否想要退出。完整代码为: import sys from PyQt4 import QtGui, QtCore class Example(QtGui.QWidget): def __init__(self): super(Example, self).__in
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()
它的工作完美如预期-大小是罚款,它是可调整大小。但是,当我使用编译代码时,文件夹对话框是全屏的,甚至无法调整大小
我怎样才能防止它发生?谢谢
编辑:
要创建等级库文件,我使用:
C:\Python\Python279\Scripts\pyi makespec--icon=icon.ico--noconsole--name=“Test”Test.py
要使用spec文件编译代码,我使用:
C:\Python\Python279\Scripts\pyi build Test.spec
嗯,我不知道PyInstaller,但是如果你说你可以按预期运行程序,但不能在用PyInstaller编译时运行,那么我想问题就出在那里了。你能介绍一下用PyInstaller创建安装程序的脚本/命令吗?问题仍然存在吗?@Trilarion编辑:)