Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3694462
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:29:58+00:00 2026-05-19T04:29:58+00:00

I’ve written a simple GUI program in python using Tkinter. Let’s call this program

  • 0

I’ve written a simple GUI program in python using Tkinter. Let’s call this program ‘gui.py’. My users run ‘gui.py’ on Windows machines from a USB key using Portable Python; installing anything on the host machine is undesirable.

I’d like my users to run ‘gui.py’ by double-clicking an icon at the root of the USB key. My users don’t care what python is, and they don’t want to use a command prompt if they don’t have to. I don’t want them to have to care what drive letter the USB key is assigned. I’d 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 couldn’t figure out how to do a relative path in a windows shortcut, and using an absolute path like “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 doesn’t seem to care what drive letter the USB key is assigned, but it does leave a DOS window open while my program runs. Functional, but ugly.

Next I tried a .bat script like this:

@echo off
set basepath=%~dp0
start "" "%basepath%App\pythonw.exe" "%basepath%\App\gui.py"

(See here for an explanation of the funny quoting)

Now, the DOS window briefly flashes on screen before my GUI opens. Less ugly! Still ugly.

How do real men deal with this problem? What’s the least ugly way to start a python Tkinter GUI on a Windows machine from a USB stick?

EDIT:
All the answers below were very good (py2exe, pyinstaller, small .exe, .wsf script.) The .wsf solution was the simplest, so I’m using it for now. I’ll probably end up switching to one of the other three solutions if I want a prettier icon and the standard .exe extension. Thanks, everyone!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:29:59+00:00Added an answer on May 19, 2026 at 4:29 am

    This Windows Scripting Host script (file extension .wsf) can be used instead of the batch file:

    <job>
    <script language="VBScript">
    set WshShell = WScript.CreateObject("WScript.Shell")
    CMDFile = "App\\pythonw.exe App\\gui.py"
    WshShell.Run CMDFile, 1
    </script>
    </job> 
    

    Update: Alternatively compile this C program and link an icon resource:

    #include <windows.h>
    #include <process.h>
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
                       LPSTR lpCmdLine, int nCmdShow)
    {
        return _spawnl(_P_NOWAIT, "App/pythonw.exe", " App/gui.py", lpCmdLine, NULL);
    }
    

    Update 2: To build an App.exe with icon, save the C code to app.c, create an Windows icon file app.ico, and save the following line to app.rc:

    appicon ICON "app.ico"
    

    Using Visual Studio 2008 Express, run these commands:

    "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"
    rc.exe app.rc
    cl.exe app.c /FeApp.exe /link app.res
    

    Alternatively use “Visual Studio 2010 Express” or “Microsoft Windows SDK v7.0 for Windows 7 and .NET Framework 3.5 Service Pack 1” and adjust the commands accordingly.

    Note that the icon will only be used for the App.exe starter program, not your Python program.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.