I wrote a simple graphical program in python using Tkinter. Call this program "gui.py". My users run "gui.py" on Windows computers using a USB key using Portable Python ; installing anything on the host machine is undesirable.
I want my users to run "gui.py" by double-clicking the icon in the root of the USB key. My users do not care about what python is and they do not want to use the command line if they do not need it. I do not want them to care about which drive letter the USB key is assigned to. I would like this to work on XP, Vista and 7.
My first ugly solution was to create a shortcut in the root directory of the USB key and set the "Target" property of the shortcut to something like "(root) \ App \ pythonw.exe (root) \ App \ gui.py", but I donโt could figure out how to make a relative path in a Windows shortcut, and using an absolute path such as "E:" seems fragile.
My next solution was to create a .bat script in the root directory of the USB key, something like this:
@echo off set basepath=%~dp0 "%basepath%App\pythonw.exe" "%basepath%\App\gui.py"
This does not seem to care about which drive letter the USB key is assigned to, but it leaves the DOS window open during my program. Functional but ugly.
Next, I tried the .bat script as follows:
@echo off set basepath=%~dp0 start "" "%basepath%App\pythonw.exe" "%basepath%\App\gui.py"
(see here for an explanation of ridiculous quoting)
Now the DOS window flashes briefly on the screen before my graphical interface opens. Less ugly! Still ugly.
How do real men deal with this problem? What is the least ugly way to run the Python Tkinter GUI on a Windows machine from a USB drive?
EDIT: All of the answers below were very good (py2exe, pyinstaller, small.exe, .wsf script.) .Wsf solution was the easiest, so I am using it now. I will probably return to one of three other solutions if I want a more beautiful icon and a standard .exe extension. Thank you all!