Very basic info for beginners, by a beginner. IDLE is the learning console that comes with most Python distributions. I am new to playing with Python and wanted to get IDLE to load when I logged into my Windows profile. I searched the internet without finding the info I wanted. I also did not find the answer in the thread Help running pythonw from a command prompt with arguments and have since figured out how to do it, so I decided to post exactly what I did and why it worked.
Some background info: IDLE is a Python script, not a native Windows machine executable. In Windows it loads differently from EXE's, MSI's, COM's, BAT's, and DLL's. To run IDLE, the system first loads either python.exe or pythonw.exe. The difference between these two are that python.exe runs inside of a text console and has support for the console's features, but pythonw does not. Pythonw is the default choice to load the file idle.pyw that is IDLE, because IDLE does not use the basic text console.
Here is what I did wrong:
In Windows Vista Ultimate after I had installed a typical binary packaged Python 2.6 from Python.org I wanted IDLE to start when I logged in, so I tried adding a link to the executable PYTHONW.EXE in my startup folder. I went onto the start menu and tried to find the executable by getting the properties info off of the IDLE link. I then copied this info into another shortcut, but all that the shortcut would do was open the Python26 folder! ? The problem was the assumption that IDLE was either an EXE or COM windows executable, which was incorrect. Instead, the Python interpreter installation set up python scripts to be loadable in Windows, and python itself was the loader.
Here is what I did right. I made a batch file containing the following two lines:
start c:\python26\pythonw.exe c:\python26\Lib\idlelib\idle.pyw %1 %2 %3 %4 %5 %6
exit
I put a link to the batch file into my startup, and it worked. When I log in, IDLE comes up. Here is the explanation of how the batch file works:
When windows opens the batch file by starting a text command console and loading the batch file. The first line in the batch file directs it to load pythonw.exe. It uses the command START to load it as a separate process, so that when the EXIT command is followed pythonw.exe will continue to run. To summarize the first line loads pythonw.exe, which in turn loads idle.pyw. Finally the EXIT command orders windows to close the text command console. At that point, Pythonw.exe has loaded and it has loaded the idle.pyw. The %number items are for passing additional information to pythonw.exe or to idle.pyw. When executing batch files from a Windows command console, you may type parameters at the end of the same line; and these will be passed to pythonw.exe by means of those %numbered items. For example if I named the batch file 'StartIdle.bat' and had called it by typing "StartIdle Cat" the letters Cat would be passed into the batch file during execution and tacked onto the end of the line in place of the %1 .