简体   繁体   中英

Get exe with Pyinstaller including pygubu

I would like to generate a portable python application, which i can share to my colleagues.

I used pygubu to create a tkinter GUI and would like to genereate a exe file with pyinstall.

After the pyinstaller PythonAppGUI.py command I get an exe. If I run the exe a command window pops-up for a second and closed ifself.

Is there any solution how i can use the pygubu-module with the 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. In the same folder is the pyapp.ui -file for the GUI

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 --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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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