Python py2exe window showing (tkinter)

py2exe, python, tkinter

Solution

I ended up encountering this same issue, my solution involved doing the following:

Add `"dll_excludes": ["tcl85.dll", "tk85.dll"],`

in your `options = {...}`

and then manually copy those two DLLs from

`PYTHON_PATH\DLLs\` (in my case `C:\Python27\DLLs`)

to the location of your exe and try running it.

Problem

I'm trying to make an exe by py2exe. The program is showing a popup-like window using Tkinter. The problem is, everything works fine when I run the setup like this: ``` setup(windows = [{'script': "msg.py"}], zipfile = None) ``` but it fails when I try to make an one-file exe: ``` setup(windows = [{'script': "msg.py"}], zipfile = None, options = {'py2exe': {'bundle_files': 1, 'compressed': True}}) ``` Actually the final exe runs without problems, but it doesn't display any window. I've read there may be problems with bundle_files=1 at Windows 7, but I also tried bundle_files=2 with the same effect. Here is my msg.py script: ``` from win32gui import FindWindow, SetForegroundWindow from Image import open as iopen from ImageTk import PhotoImage from Tkinter import Tk, Label from threading import Timer from subprocess import Popen import os def Thread(t, fun, arg=None): if arg<>None: x = Timer(t, fun, arg) else: x = Timer(t, fun) x.daemon = True x.start() def NewMessage(): global root if not os.path.exists('dane/MSG'): open('dane/MSG', 'w').write('') root = Tk() img = PhotoImage(iopen("incl/nowa.png")) label = Label(root, image=img) label.image = img label.bind("<Button-1>", Click) label.pack() root.geometry('-0-40') root.wm_attributes("-topmost", 1) root.overrideredirect(1) root.mainloop() def Click(event): global root, exit root.destroy() os.remove('dane/MSG') OpenApp() exit = True def OpenApp(): hwnd = FindWindow(None, 'My program name') if hwnd: SetForegroundWindow(hwnd) else: Popen('app.exe') root, exit = None, False NewMessage() ``` Any ideas? I've read there are some problems with Tkinter, but there were about compilation. My script is compiled and it doesn't throw any exceptions, but doesn't show the window...

Original source