For a very simple example, consider the following code
import tkinter as tk
from tkinter import messagebox
class App:
def __init__(self, parent):
# some widgets
label = tk.Label(parent, text="Label")
button = tk.Button(parent, text="button")
label.pack()
button.pack()
# and a menu
menu = tk.Menu(parent)
parent.config(menu=menu)
Menu1 = tk.Menu(menu)
menu.add_cascade(label="Menu", menu=Menu1)
for x in 'ABCD':
Menu1.add_command(label="Menu " + x,
command=lambda y=x: messagebox.showinfo(message=y))
if __name__ == '__main__':
root = tk.Tk()
root.geometry("250x100+100+50")
root.title("My humble GUI")
App(root)
root.mainloop()
which produces a window like so:
After running pyinstaller --onefile --noconsole minimal.py
(the name of the code file is minimal.py
), I obtain, in the dist
folder a bundle file (the app) which, when run, gives me the following:
The menu works just normally (that's the reason for which I included it; it's not really minimal, but it shows that something's working...), but none of the widgets in the window are visible (not to mention the black color of the window, which I suppose is related to the problem).
It also happens that when I double click the app icon to open it, it tries to open it (the icon shows up in the dock bar for a second), and then it opens it for good after two seconds, more or less; this also doesn't seem normal.
What should I do? Thanks