PySyde2 / fbs冻结/无法执行脚本主程序

问题描述 投票:0回答:1

希望你们做的很好!我正在使用PyCharm和虚拟环境开始一个项目。有人可以帮忙吗?我有这些文件:

带有代码的main.py:

from fbs_runtime.application_context.PySide2 import ApplicationContext
import sys
from package.main_window import MainWindow
if __name__ == '__main__':
    appctxt = ApplicationContext()       # 1. Instantiate ApplicationContext
    window = MainWindow()
    window.resize(250, 150)
    window.show()
    exit_code = appctxt.app.exec_()      # 2. Invoke appctxt.app.exec_()
    sys.exit(exit_code)

我还有另一个文件main_window.py,其中包含以下代码:从PySide2导入QtWidgets

class MainWindow(QtWidgets.QWidget):
    def __init__(self):
        super().__init__()
        self.setup_ui()

    def setup_ui(self):
        self.create_widgets()
        self.modify_widgets()
        self.create_layouts()
        self.add_widgets_to_layouts()
        self.setup_connections()

    def create_widgets(self):
        self.btn_click = QtWidgets.QPushButton("Click")

    def modify_widgets(self):
        pass

    def create_layouts(self):
        self.main_layout = QtWidgets.QVBoxLayout(self)

    def add_widgets_to_layouts(self):
        self.main_layout.addWidget(self.btn_click)

    def setup_connections(self):
        self.btn_click.clicked.connect(self.bouton_clicked)

    def bouton_clicked(self):
        message_box = QtWidgets.QMessageBox()
        message_box.setWindowTitle("Bravo")
        message_box.setText("Première application réussi")
        message_box.exec_()

最后,我用以下命令创建了一个freeze.sh文件:源〜/ PycharmProjects / venv / Scripts / activatecd〜/ PycharmProjects / echaufement /

fbs clean
fbs freeze

我CD了src / main文件夹并使用了usig:sh Frozen.sh它创建一个包含我的App.exe的目标文件夹但是打开我的App.exe时出现以下错误:无法执行脚本main最后在调试-fbs Frozen --debug-之后,我有了这个-请查看图片感谢您的帮助。enter image description here

python pycharm pyside2 fbs
1个回答
0
投票

./Scripts/fbs-script.py第11行是否存在路径问题?

同样,fbs在python 3.6之外的播放效果也不佳。尝试在python 3.6.x venv时再次冻结该应用程序吗?

© www.soinside.com 2019 - 2024. All rights reserved.