Working example of script with python?

ActivePython with xyzzy's script results in the error shown below when I save the script to Opus' Script Addins folder. What am I doing wrong?

I also tried Python.org's v3.4 and, like sfranky, consistently get the error "Script Engine 'python' could not be opened". sfranky, did you ever manage to get a Python script to work?

I'm running Opus v11.4.1 64-bit.

Regards, AB


Script add-ins don't use @script.

[quote="aussieboykie"]
I also tried Python.org's v3.4 and, like sfranky, consistently get the error "Script Engine 'python' could not be opened".[/quote]

Have you installed pywin32 as well (despite its name - it has also 64-bit version)? This is what enables Windows-specific 'things' in python.

@aussieboykie: nope, but i'm not really aware of how this whole thing works. I didn't even know there was a difference between script add-ins and other scripts.

After Jon pointed out my problem (see above) I copied your code into a button.

[code]@script Python

def OnClick(clickData):
dlg = clickData.func.Dlg
dlg.message = 'a'
dlg.buttons='bb|cc'
dlg.icon='info'
dlg.title='ala'
dlg.Show[/code]
When clicked, the script runs, apparently successfully, but no dialog pops up.

Successfully initialized 'Python' engine Script started successfully Script completed
What am I missing? Do I need to install pywin32 in addition to ActivePython? Anything else?

Regards, AB

For ActivePython you don't need pywin32 - it's included. You need it only for plain python.org version.
Could you check if the popped-up dialog is not hidden somewhere in the background?
Could you try to change dlg.Show into dlg.Show() (I remember some strange things around this call - and still I am not sure why it worked without () for me)

i still can't make anything work ;(
Script Engine 'Python' could not be opened..

[quote="sfranky"]i still can't make anything work ;(
Script Engine 'Python' could not be opened..[/quote]

ActivePython? Did you run pyscript.py --register? What was the output?

You can always post to python-win32 mailing list. Mark Hammond answers there.

Can you make it work with wscript and some short pys script? Some samples here: icodeguru.com/WebServer/Pyth ... 2/ch21.htm

Xyzzy - I am intrigued as to how you are able to get your Python driven dialog to work from a button. I have now tried your button code in two clean Windows 7 64-bit VMs, one configured with ActivePython and the other with Python.org + PyWin. In both environments, the button generates log output indicating no errors..

Successfully initialized 'Python' engine Script started successfully Script completed
.. but no pop-up dialog ever appears. Python is evidently registered properly on my system as confirmed by the successfully initialised message. I am using Opus 11.4.1 (Beta) x64 with a stock configuration. Any idea as to what you might have done that I have not?

Regards, AB

[quote="aussieboykie"]Xyzzy - I am intrigued as to how you are able to get your Python driven dialog to work from a button. I have now tried your button code in two clean Windows 7 64-bit VMs, one configured with ActivePython and the other with Python.org + PyWin. In both environments, the button generates log output indicating no errors..
[/quote]

I will check this sample again with the latest DO and post results.

[quote="Xyzzy"]
I will check this sample again with the latest DO and post results.[/quote]

Hmm, it just works here.

I took a fresh VM of W2k8 R2 64-bit (no Win 7 at hand) with some base software (antivirus, drivers - no updates).
Installed the following packets in this order (no reboots, all default selections for python packages, all integration/replacement options for DO unselected in installer):

  • python-3.4.0.amd64.msi
  • pywin32-219.win-amd64-py3.4.exe
  • DOpusInstall64.exe ( 11.4 b5229)

Created button


Clicked it and got the dialog


Could you try to debug data to a file or DO log? Do you get dlg object correctly, what Show returns etc?

Aaargh! A basic error on my behalf. I had the button set as a STANDARD button instead of a SCRIPT button.

Apologies.... AB :blush:

Xyzzy, would you mind posting a sample script to demonstrate using the DOpus object with Python?

Regards, AB

[quote="Xyzzy"][quote="sfranky"]i still can't make anything work ;(
Script Engine 'Python' could not be opened..[/quote]

ActivePython? Did you run pyscript.py --register? What was the output?

You can always post to python-win32 mailing list. Mark Hammond answers there.

Can you make it work with wscript and some short pys script? Some samples here: icodeguru.com/WebServer/Pyth ... 2/ch21.htm[/quote]

sorry for the late reply, i'm struggling to find some free time to test this..thanks for the suggestions!
The pyscript.py --register was the first thing you suggested, so yes, i tried that and it seems to be working fine:

Requesting elevation and retrying...
Registered: Python

I had also tried some activescript tests as proposed by you again i think, and they seemed to be working.
Any other suggestions? Anyone?

No need. I played around some more and have managed to get some simple stuff working with the DOpus object. Not everything works as expected but given that (a) Python is not formally supported and (b) I'm no Python expert, I will keep quiet and wait to see what develops.

Regards, AB

No need. I played around some more and have managed to get some simple stuff working with the DOpus object. Not everything works as expected but given that (a) Python is not formally supported and (b) I'm no Python expert, I will keep quiet and wait to see what develops.
[/quote]

Good you made if work. There are some still issues I post to this forum - adding (python) to subject. Please post there if you have different observations.

What about are you talking about? Python? Or ActivePython? ActivePython is not a must, it is just convenient packaging. As for Python + pywin32, there is lots of support. Mark Hammond, the author of pywin32, answers questions related to pywin32, much as you do here.
No support, no community? Please... : wiki.python.org/moin/LocalUserGroups

And here's actual TIOBE tiobe.com/index.php/content/ ... index.html

ActivePython.

I know a lot of people use Python but the issues you're raising are specific to ActivePython and there seems to be very little about it on the web to help solve them, since so few applications have supported ActivePython hosted inside of them. As I predicted, we solved one issue only to now have three more, and using JScript is still the better option.

I'm sure they are all solvable but researching and debugging ActivePython issues could use up a lot of time as a result of it being largely uncharted territory. All so a small number of can use one scripting language instead of another very similar language (and create scripts nobody else can use without the hassle of downloading and manually registering bits of a 3rd party package, with the added confusion and compatibility issues of there being two packages to choose from...).

I'm not against making as many languages work as possible in Opus in theory, but in practise it may not be the best way for us to invest our time. I urge everyone to consider sticking to the beaten path as it will be easier in the long run. The differences between languages are trivial for most tasks. (And where something is missing, we can always add an Opus object to provide similar functionality to JScript and VBScript if it makes sense.)

I've dropped ActivePython in favor of python.org python + pywin32 (the latest release - 4 days ago).
There are two packages to install instead of one, but, other than that, I have noticed no set-up differences, and you have (lots of) support - like 24/7 channel on IRC with 1500 ppl actually giving answers. All issues reported by me lately are related to pywin32. They may be pywin32 problems (which is expected to be fixed on pywin32 site), DOpus problems (which you may or may not fix), or my problems (as I have had almost nothing to do with ActiveScripting so far, and COM is philosophy on its own).

I do not ride my horse exclusively, as it seems a couple of people is interested.

As I've stated, for a couple of small tasks there is not a lot of difference, and I am not evangelizing around here. For anything bigger, it simply really makes a difference.