Re: [python-win32] running a python script on WinXP by icon double-clicking.

2010-08-04 Thread Gelonida
On 08/04/2010 08:30 AM, Vineet Deodhar wrote:
> I have created a py2.6 script for a simple GUI with Tkinter.
> Saved it with .py extension and also as .pyw extension.
> 
> filename is entry.py
> [CODE]
> from Tkinter import *
> from quitter import Quitter
> 
> def fetch():
> print('Input => "%s"' % ent.get())
> 
> root = Tk()
> ent = Entry(root)
> ent.show='@'
> ent.insert(0, 'Type words here')
> ent.pack(side=TOP, fill=X)
> 
> ent.focus()
> ent.bind('', (lambda event: fetch()))
> btn = Button(root, text='Fetch', command=fetch)
> btn.pack(side=LEFT)
> Quitter(root).pack(side=RIGHT)
> root.mainloop()
> [/CODE]
> 
> 1) When run from command prompt as --- 
> D:\py>python entry.py
> it runs nicely.
> 
> 2) If I double-click on either entry.py or entry.pyw file, 
> nothing happens (no DOS console window to show any error also).
> 
Do you have any other python script that works by clicking on it?

I assume, that you r windows file types are not registered correctly.

Do you have multiple version of python installed?


try following twwo commands to see whether windows was made aware of the
python file types

assoc .py
assoc .pyw
you should have received as answers
.py=Python.File

and
.pyw=Python.NoConFile

respectively

if you don't see this just type:
assoc .py=Python.File

and
assoc pyw=Python.NoConFile




type also the command

ftype Python.File

you should see something like
Python.NoConFile="C:\Python26\pythonw.exe" "%1" %*

(depending where your py.exe is installed)

perhaps this entry is wrong and points still to an executable that
doesn't exist anymmore

just type

ftype Python.NoConFile="C:\Python26\pythonw.exe" "%1" %*

(or with thy path to python.exe adapted) to fix it.


then try the same with
ftype Python.NoConFile



> 
> 
> 
> ___
> python-win32 mailing list
> python-win32@python.org
> http://mail.python.org/mailman/listinfo/python-win32


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] running a python script on WinXP by icon double-clicking.

2010-08-04 Thread Vineet Deodhar
Hi Kevin,
I checked "Opens with" option for .py and .pyw files.
Associations are correct.

This problem happens for any python script file, not just this-one.
Do I really need to remove & reinstall py26, or can there any other option !

---Vineet.



--- On Wed, 4/8/10, Kevin Horn  wrote:

From: Kevin Horn 
Subject: Re: [python-win32] running a python script on WinXP by icon  
double-clicking.
To: "Vineet Deodhar" 
Date: Wednesday, 4 August, 2010, 12:11

First check that .py or .pyw files are associated with the proper executables.

from an explorer window, choose Tools -> Folder Options
then click on the file types tab

find the PY and PYW entries in the list, and make sure their "Opens with" 
entries are correct


PY -> python.exe
PY -> pythonw.exe

If those are correct, and you still have problems, then perhaps your python 
installation is messed up somehow,
or there's something really strange about your script.


Hope this helps,
Kevin Horn

On Wed, Aug 4, 2010 at 1:30 AM, Vineet Deodhar  wrote:

I have created a py2.6 script for a simple GUI with Tkinter.
Saved it with .py extension and also as .pyw extension.


filename is entry.py
[CODE]
from Tkinter import *
from quitter import Quitter

def fetch():
    print('Input => "%s"' % ent.get())

root = Tk()
ent = Entry(root)
ent.show='@'

ent.insert(0, 'Type words here')
ent.pack(side=TOP, fill=X)

ent.focus()
ent.bind('', (lambda event: fetch()))
btn = Button(root, text='Fetch', command=fetch)
btn.pack(side=LEFT)

Quitter(root).pack(side=RIGHT)
root.mainloop()
[/CODE]

1) When run from command prompt as --- 
D:\py>python entry.py
it runs nicely.

2) If I double-click on either entry.py or entry.pyw file, 

nothing happens (no DOS console window to show any error also).

Any idea
 how should I run this with double-click on icon!

Thanks,
Vineet.




  
___

python-win32 mailing list

python-win32@python.org

http://mail.python.org/mailman/listinfo/python-win32







  ___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Strange problems using Python inside Windows Script Components (WSC)

2010-08-04 Thread Erik Oosterwaal
Hi All,

I'm using Python inside a Windows Script Component (.wsc). I instantiate
the WSC and call the code from classic ASP using VBscript. Now I'm
running into a couple of problems:

The standard ASP objects seem not to be available to Python in the WSC,
even though the WSC has the implements ASP tag: 
I have a workaround for this; I pass an object to the WSC that has all
of the standard IIS objects like request, response, session etc. as a
property. Using that I -am- able to access the standard IIS objects, but
it's obviously not an ideal solution. The code looks like this:

def openGM(superObject):
"""places all of the projects and ASP objects into a global context
so we can use it from inside the entire wsc."""
global request, response, application, session, translate, debug,
usr, datatyping, dal, server
request = superObject.Request
response = superObject.Response
application = superObject.Application
session = superObject.Session
...etc

 The second problem I'm running into is debugging.

Because I'm running the code from inside a WSC, which is in fact an
active script component, the ASP page calling the WSC doesn't give me a
descriptive error when there's something wrong in the WSC code. 
 When developing in VBscript (at least locally), errors in the WSC will
trigger Visual Studio, or another external debugger and allow me to
debug the WSC code. PyScript doesn't seem to trigger anything. 
I have seen the axdebug module in the win32 extentions, but I have no
idea how to implement this. Is it supposed to work out of the box, or is
there something I need to do, to enable debugging from inside a WSC ? 
I have also tried importing win32traceutil, but that only seems to work
for stdout. If I use the Python print() command from my WSC, the text
will show up in the trace collector window, but errors don't. I was
under the impression that both stdout and stderr were redirected to the
trace collector?
I have also seen suggstions around the Internet to use the --debug
option when registering a component, but this is a script-component, and
I use it exclusively without registration, using the getObject()
function like so:

set pythonwsc =
GetObject("script:"&Server.MapPath("/components/python.wsc"))

Does anyone perhaps have any tips or suggestions I might use to be able
to debug in such a situation? 

The last problem I have, is a very strange one. The module I'm
re-writing in Python is a translation module. What it does is read a
bunch of XML data into a few dictionaries. It then writes those
dictionaries (one for each supported language) into a file using
Python's "shelve". This all works fine. I have a LoadData() function
that checks if there already is a shelve file, if not it will load the
XML (which is always present) and create the shelve file. If the file
already exists, it wil just load the file and use the dictionaries
inside, pretty simple.

I have a global dictionary simply called "d" in my code, and after I
fill or load it, it is available. Then I call the function to give me a
translation for one of the dictionary keys, and all of a sudden "d" is
empty. I have tried defining d outside of all of the functions in the
WSC using d = {}, I have also tried defining d at the moment data is
loaded or created using the gloabal keyword; "global d". Both methods
didn't work. The workaround I have is to create a new global variable in
the function that loads the dictionary and assigning d to that. Here's
what that looks like:

def loadDataFromDAT(filepath):
response.write("Load data from .DAT file")
translation_db = shelve.open(filepath)
d = translation_db[str(usr.var("lcid"))]
#response.write("After loading data: " + str(d.keys()))
global currentDictionary
currentDictionary = d

The strange thing is that d has values in this function, but when I call
my "label()" function, which looks up a value for a key in the
dictionary, it no longer has values, even though it is defined in
another function as a global, or defined outside all of the functions
(making it a global variable). If I then use "currentDictionary", it
DOES have values.  So the question is, what is the best way in a WSC to
create a global variable, that works across functions inside the WSC?

Thanks a lot  for any answers or leads you guys can give me. The
internet isn't exactly littered with information about Pyscrpt in WSC's
I'm afraid, so I hope someone can shed some light on this. 

Kind regards,

Erik

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] running a python script on WinXP by icon double-clicking.

2010-08-04 Thread Tim Roberts
 Vineet Deodhar wrote:
> I have created a py2.6 script for a simple GUI with Tkinter.
> Saved it with .py extension and also as .pyw extension.
> ...
> 1) When run from command prompt as ---
> D:\py>python entry.py
> it runs nicely.
>
> 2) If I double-click on either entry.py or entry.pyw file,
> nothing happens (no DOS console window to show any error also).
>
> Any idea how should I run this with double-click on icon!
>
>

Does it run if you type just the file name?  For example:
D:\py>entry.py
or
D:\py>entry.pyw

If it runs like that, then it should run from a double-click.  Do you
have multiple versions of Python installed?  Is "Quitter.py" in the same
directory as the script?  Can you check the associations from a command
line using the assoc and ftype commands, like this:

C:\tmp>assoc .py
.py=Python.File

C:\tmp>assoc .pyw
.pyw=Python.NoConFile

C:\tmp>ftype python.file
python.file="C:\Apps\Python26\python.exe" "%1" %*

C:\tmp>ftype python.noconfile
python.noconfile="C:\Apps\Python26\pythonw.exe" "%1" %*

Your path will probably be different, but the philosophy should be the same.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32