简体   繁体   English

使用包括 pygubu 在内的 Pyinstaller 获取 exe

[英]Get exe with Pyinstaller including pygubu

I would like to generate a portable python application, which i can share to my colleagues.我想生成一个可移植的 python 应用程序,我可以与我的同事分享。

I used pygubu to create a tkinter GUI and would like to genereate a exe file with pyinstall.我使用 pygubu 创建了一个 tkinter GUI,并想用 pyinstall 生成一个 exe 文件。

After the pyinstaller PythonAppGUI.py command I get an exe.pyinstaller PythonAppGUI.py命令之后,我得到了一个 exe。 If I run the exe a command window pops-up for a second and closed ifself.如果我运行 exe 命令窗口会弹出一秒钟并关闭 ifself。

Is there any solution how i can use the pygubu-module with the pyinstaller.有什么解决方案可以让我将 pygubu 模块与 pyinstaller 一起使用。 All other provided soltion on the internet are not really helpfull.互联网上提供的所有其他解决方案都没有真正的帮助。

Thanks a lot.非常感谢。

My python-template-code with which i am trying to generate a exe.我试图用它生成一个 exe 的 python-template-code。 In the same folder is the pyapp.ui -file for the GUI在同一个文件夹中是 GUI 的pyapp.ui文件

import tkinter as tk
import pygubu


class Menu:
 
    def __init__(self, master):

        self.master=master
        #Create builder
        self.builder = builder = pygubu.Builder()
        #Load ui file
        builder.add_from_file('pyapp.ui')
        #Create a widget, using master as a parent
        self.mainwindow = builder.get_object('mainframe', master)

        #Connect callbacks
        builder.connect_callbacks(self)
    
    def but1(self):
        pass

    def but2(self):
        pass
    
               

if __name__ == '__main__':
    #Start Menu GUI
    root = tk.Tk()
    app = Menu(root)
    root.mainloop()

Pyinstaller may not be adding pyapp.ui to the directory automatically, try; pyinstaller 可能没有自动将pyapp.ui添加到目录中,试试;

pyinstaller --add-data "pyapp.ui;." PythonAppGUI.py

the command copies pyapp.ui to the root directoy of the executable where i believe PythonAppGUI.py is exepecting it to be该命令将pyapp.ui复制到可执行文件的根目录,我相信PythonAppGUI.py期望它是

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM