[Tutor] Further help needed!

Alan Gauld alan.gauld at freenet.co.uk
Wed Jan 4 23:35:48 CET 2006


John,

On Win 9X try
1) copying the text file to PRN: using os.system()
2) use the DIS PRINT command using os.system()
3) Try opening the file LPT1: and copying your text to that.

All of the above should work. But I no onger have a
Win9X box to check...

HTH,

Alan G.

----- Original Message ----- 
From: "John Corry" <john.corry at ntlword.com>
To: <tutor at python.org>
Sent: Wednesday, January 04, 2006 9:01 PM
Subject: [Tutor] Further help needed!


>I am using the following code to send a text file to the printer:-
>
> import win32api
> filename = "testprint.txt"
> fileobj=open (filename, "w")
> fileobj.write ("This is a test")
> fileobj.close()
> win32api.ShellExecute (
>  0,
>  "print",
>  filename,
>  None,
>  ".",
>  0
> )
>
> This code works on windows XP + Windows 2000.  However it does not work on
> windows 98SE.  I have tried this code on 3 seperate machines with windows
> 98SE.  They all come up with the same error:
>
> File
> "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
> line 310, in RunScript
>    exec codeObject in __main__.__dict__
>  File "C:\test\Script1.py", line 12, in ?
>    0
> error: (31, 'ShellExecute', 'A device attached to the system is not
> functioning.')
>
> Is there another way to print out a text file on windows 98SE?  Do I have 
> to
> do something different on the windows 98SE machine?  Any help would be
> greatly appreciated.
>
> Thanks,
>
> John.
>
>
> 



More information about the Tutor mailing list