簡體   English   中英

使用包括 pygubu 在內的 Pyinstaller 獲取 exe

[英]Get exe with Pyinstaller including pygubu

我想生成一個可移植的 python 應用程序,我可以與我的同事分享。

我使用 pygubu 創建了一個 tkinter GUI,並想用 pyinstall 生成一個 exe 文件。

pyinstaller PythonAppGUI.py命令之后,我得到了一個 exe。 如果我運行 exe 命令窗口會彈出一秒鍾並關閉 ifself。

有什么解決方案可以讓我將 pygubu 模塊與 pyinstaller 一起使用。 互聯網上提供的所有其他解決方案都沒有真正的幫助。

非常感謝。

我試圖用它生成一個 exe 的 python-template-code。 在同一個文件夾中是 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 可能沒有自動將pyapp.ui添加到目錄中,試試;

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

該命令將pyapp.ui復制到可執行文件的根目錄,我相信PythonAppGUI.py期望它是

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM