[Tutor] Nearly there
John Corry
john.corry at ntlword.com
Sat Jan 7 11:57:26 CET 2006
Terry,
Your suggestion works. It also works consistently if you fully define the
path of 'filename'.
eg
filename = "c:/test/testprint.txt"
You are right, shell execute seems to need the full path name with windows
98SE. It is strange that it does not need the full path for win xp + win
2k.
Onto my next problem.
My text file is printing out in portrait. Is there any instruction that I
can use so that notepad prints it in landscape?
Thanks,
John.
-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org]On
Behalf Of Terry Carroll
Sent: 07 January 2006 00:24
To: tutor at python.org
Subject: Re: [Tutor] Nearly there
This is itching at me, too.
On Fri, 6 Jan 2006, John Corry wrote:
> Can anyone understand or tell me why this works but the following code
does
> not:-
>
> import win32api
> filename = "testprint.txt"
> fileobj=open (filename, "w")
> fileobj.write ("This is a test")
> fileobj.close()
> win32api.ShellExecute (
> 0,
> "print",
> filename,
> None,
> ".",
> 0
> )
I'm wondering if ShellExecute needs a full path to find it under W98.
Try this; add to the top of your code:
import os.path
and change your ShellExecute to this:
win32api.ShellExecute (
0,
"print",
os.path.abspath(filename),
None,
".",
0
)
I have no idea if this will work; and the error message you're getting,
> The code above gives me the error: (31, 'ShellExecute', 'A device attached
> to the system is not functioning.')
doesn't seem to indicate it, but it's one less thing.
I'd love to know the answer when you get it.
_______________________________________________
Tutor maillist - Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list