[FRPythoneers] Python under MSWindows

Clementson, Bill Bill_Clementson at jdedwards.com
Fri Jun 1 16:01:22 MDT 2001


If you just want to redirect stdout to a file and display it to the user,
the following will do the job (it is a bit clunky but it works and doesn't
require any changes to your python code):

1. Create a batch file (called runit.bat in this example) containing the
following lines:
python %1 %2 %3 %4 %5 %6 %7 %8 %9 > %temp%\temp
notepad.exe %temp%\temp
del %temp%\temp

2. Create a shortcut to the batch file & rename it as appropriate

3. Right-click on the shortcut, select Properties & change the Target to
include the python program and any args. For example:

C:\python\tools\runit.bat C:\python\printargs.py hello world

4. Now, double click on the shortcut & your program output should appear in
notepad for viewing. 

-Bill

-----Original Message-----
From: J. Wayde Allen [mailto:wallen at its.bldrdoc.gov]
Sent: Friday, June 01, 2001 3:13 PM
To: frpythoneers at lists.community.tummy.com
Subject: Re: [FRPythoneers] Python under MSWindows


On Fri, 1 Jun 2001, Evelyn Mitchell wrote:

> On Fri, Jun 01, 2001 at 02:09:34PM -0600, J. Wayde Allen wrote:
> > On Fri, 1 Jun 2001, Evelyn Mitchell wrote:
> > 
> >     C:\Wayde\myprogram.pyw argument1
> 
> Try calling it with .py rather than .pyw
> I thought you were trying to avoid the DOS box, rather than
> keep it around.

OK, changing the target line back to:

   C:\Wayde\myprogram.py argument1

and adding a raw_input() at the bottom of the code does run the program,
and leave the output screen with data.  However, the screen isn't
scroll-able.  That ends up being kind of useless since I'm generating more
data than fits in the tiny little window.

So ... evidently one can't simply write a piece of Python code and
transport it to a MSWindows machine without adding code to open Windows,
etc.?  I'm not too sure how to phrase the question I guess.  Another way
of putting it is that it seems one is compelled to create a GUI interface
to one's code.  You can't just run the code and have it open a window (or
more precisely, a particularly useful window that is resizable with
scroll bars) for program input and output?

I haven't played with MSWindows for a long time, but it also looks like
file redirection from within the MSWindows environment is also
gone.  Simply setting the target line to something like:

     C:\Wayde\myprogram.py argument1 > C:\Wayde\result.txt

doesn't create anything as far as I can tell.  

At least one can open the DOS window and run the program that way.  The
results can then be displayed using something like notepad.

- Wayde
  (wallen at its.bldrdoc.gov)

_______________________________________________
This message sent by the FRPythoneers mailing list.
Unsubscribe: echo unsubscribe |
FRPythoneers-request at lists.community.tummy.com
URL: http://lists.community.tummy.com/mailman/listinfo/frpythoneers



More information about the FRPythoneers mailing list