mirror of
https://github.com/brentvollebregt/auto-py-to-exe.git
synced 2026-04-25 11:45:49 +03:00
[GH-ISSUE #164] Message box does not open #153
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Ferro1945 on GitHub (Apr 18, 2021).
Original GitHub issue: https://github.com/brentvollebregt/auto-py-to-exe/issues/164
My best thanks for this wonderful program! Using just pyinstaller I never managed to get a working .exe file, but with auto-py-to-exe I succeeded easily. Only one problem: I use a Message box in my Tkinter-based program. It does not open in .exe. Should I somehow tell to auto-py-to-exe about the Message box?
@brentvollebregt commented on GitHub (Apr 18, 2021):
Could you please provide a minimum working example of your issue?
@Ferro1945 commented on GitHub (Apr 21, 2021):
Hi Brent,
and thanks for your rapid answer. Actually, I found the reason myself.
Using Thonny as my editor I wrote a short program with a message box.
When run in Thonny, the program worked all right. Then, I used
auto-py-to-exe to get the .exe file, and ran it. Again the same problem:
no message. Then it somehow came to my mind that perhaps I should run
the Python code in another editor. I took the program to VS Code, and
ran it. Now, after clicking the button to show the message I got an
error message: AttributeError: module 'tkinter' has no attribute
'messagebox'. I then found in internet that some other programmers had
got the same error message, and the reason is in Tkinter. One answer
told that
|"messagebox|, along with some other modules like |filedialog|, does not
automatically get imported when you |import tkinter|. Import it
explicitly, using |as| and/or |from| as desired."
When I added this import, VS Code no more gave any error message, and
the .exe file worked all right.
Anyway, I include the code for your information.
WBR,
Esko
Brent Vollebregt kirjoitti 18.4.2021 klo 22.59:
Example program with MessageBox widget
Esko T. Rautanen 21.4.2021
import tkinter as tk
from tkinter import messagebox # This line had to be added.
class Example:
root = tk.Tk ()
master = Example (root)
root.mainloop ()
@brentvollebregt commented on GitHub (Apr 21, 2021):
Sounds like Thonny may have been importing some things that were appearing in your runtime.
Typically when a script does not run the same as an .exe compared to the packaged .py, I recommend double-clicking the .py script or use
python <script.py>in cmd to run it as the exe would.Glad you found a solution. I'll close this issue as I do not believe there is anything wrong anymore.