Python in HTAs

  • Thread starter Marcel van den Dungen
  • Start date
M

Marcel van den Dungen

Does anybody know how to use Python as the scripting language for HTML
applications? I tried the following, but I get a script error ('Object
expected') on the body element.

<html>
<head>
<title>Python controlled HTML application</title>
<hta:application id="oApplication">
<script language="python">
def Onload():
alert('hello from python')
document.all["idspan"] = 'hello from python'
</script>
</head>
<body onload="Onload();">
<span id="idspan" ></span>
</body>
</html>

Could not find any example on Google either.

TIA,
Marcel
 
R

Robby Russell

Does anybody know how to use Python as the scripting language for HTML
applications? I tried the following, but I get a script error ('Object
expected') on the body element.

<html>
<head>
<title>Python controlled HTML application</title>
<hta:application id="oApplication">
<script language="python">
def Onload():
alert('hello from python')
document.all["idspan"] = 'hello from python'
</script>
</head>
<body onload="Onload();">
<span id="idspan" ></span>
</body>
</html>

Could not find any example on Google either.

TIA,
Marcel

This isn't going to work unless your browser has some special plugin to
allow python scripts to run in it. Google probably turned up nothing as
you might be one of the first people to consider this. ;-)

-Robby

--
/***************************************
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON | www.planetargon.com
* Portland, OR | (e-mail address removed)
* 503.351.4730 | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
****************************************/


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQBBcutM0QaQZBaqXgwRAgXLAJ9ia+uquxucg0sQRNJZcK/ww4RC8ACfdkz6
HGbjr88Tdtn5wWnleO6tkpY=
=ltqY
-----END PGP SIGNATURE-----
 
R

Robby Russell

Does anybody know how to use Python as the scripting language for HTML
applications? I tried the following, but I get a script error ('Object
expected') on the body element.

<html>
<head>
<title>Python controlled HTML application</title>
<hta:application id="oApplication">
<script language="python">
def Onload():
alert('hello from python')
document.all["idspan"] = 'hello from python'
</script>
</head>
<body onload="Onload();">
<span id="idspan" ></span>
</body>
</html>

Could not find any example on Google either.

TIA,
Marcel

This isn't going to work unless your browser has some special plugin to
allow python scripts to run in it. Google probably turned up nothing as
you might be one of the first people to consider this. ;-)

-Robby

--
/***************************************
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON | www.planetargon.com
* Portland, OR | (e-mail address removed)
* 503.351.4730 | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
****************************************/


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQBBcutN0QaQZBaqXgwRAkysAKDY3gGNKSsgrGjUqpzrWPvlNfnocQCfaTrY
6AJyz9Ca/dZ3RlMdpl53iF4=
=q+jF
-----END PGP SIGNATURE-----
 
R

Roger

Robby Russell wrote:

This isn't going to work unless your browser has some special plugin to
allow python scripts to run in it. Google probably turned up nothing as
you might be one of the first people to consider this. ;-)

IIRC, years ago there was a Python plug-in for Netscape.....long before
Mozilla was born.
 
M

Michel Claveau - abstraction méta-galactique non t

Hi !

I search also this solution : use Python in .HTA
There are a "active scripting" in PyWin (from Mark Hammond). But I had never
can use it.
I actually use Python via a COM-server, and I add, in .HTA, Javascript
scripts for dialog. It's playable (by COM, I can also pass, like parameter,
array in javascript like list in Python, it's fun).

But if you can to do better, I am very very interesting.

@-salutations (and sorry for my bad english)
--
Michel Claveau
mél : http://cerbermail.com/?6J1TthIa8B




PS : see, also, in the directory axscript, in pywin (site-packages) ; or the
file 'calc.htm'
 
M

Marcel van den Dungen

Robby Russell said:
This isn't going to work unless your browser has some special plugin to
allow python scripts to run in it. Google probably turned up nothing as
you might be one of the first people to consider this. ;-)

-Robby
Well, that would be too much credit ;-)
PythonCard once shipped with 2 HTAs written in Python (Pyker.hta and
PykerLaunch.hta). I managed to plug them from CVS, but could not get them
to work either.

Why is it possible to use Python from ASP, but not from an HTA?

Thanks,
Marcel
 
M

Marcel van den Dungen

Roger said:
IIRC, years ago there was a Python plug-in for Netscape.....long before
Mozilla was born.

I'm not trying to use Python as a scripting language in HTML pages.
HTAs are HTML applications that run as trusted applications outside
the sandbox.

Marcel.
 
R

Roger Irwin

Marcel said:
Well, that would be too much credit ;-)
PythonCard once shipped with 2 HTAs written in Python (Pyker.hta and
PykerLaunch.hta). I managed to plug them from CVS, but could not get them
to work either.

Why is it possible to use Python from ASP, but not from an HTA?

Thanks,
Marcel
No expert on this, but ASP's run in the Server and hence a subset of the
local environment, whilst HTA's run in the browser space. Not running in
the sandbox means they can invoke applications, but none the less a
browser cannot automatically launch a python script unless it knows how
to launch it.

IMHO, an advantage of an HTA is that it is a generic form that isolates
itself from specifics of the local environment and hence simplifies
deployment. Instead of your application targetting a specific machine
environment it is targeting a generic environment which is encapsulated
in the browser and hence it is possible to create a specific environment
which is isolated from local machine characteristics. OTOH, ASP's are
targetting the http server environment which is usually an extension of
the local machine.
 
E

Elbert Lev

Does anybody know how to use Python as the scripting language for HTML
applications? I tried the following, but I get a script error ('Object
expected') on the body element.
..................
Could not find any example on Google either.

TIA,
Marcel

Look for "python active scripting" on google. Take into account that
enabling python scripting in html/hta is potentially not safe, and can
not be made such right now (unless you redo it from scrach).
 
G

gnu valued customer

Marcel van den Dungen said:
Does anybody know how to use Python as the scripting language for HTML
applications? I tried the following, but I get a script error ('Object
expected') on the body element.

(Using Win2k sp3 with IE 6 sp1,
Active Python 2.3)

You need to use a version of Python with a registered
script engine supporting Active Scripting (Win32 only).

Save your code with the HTA extension. Be reminded that an
HTA is hosted by mshta.exe not Internet Explorer.

To run your code here, I made one small correction
below. I edit with UltraEdit32. After making the change
I pressed the "Run in Default Browser" switch
and it worked.

hth,
tlviewer
<html>
<head>
<title>Python controlled HTML application</title>
<hta:application id="oApplication">
<script language="python">
def Onload():
alert('hello from python')
document.all["idspan"] = 'hello from python'

document.getElementById('idspan').innerHTML = 'hello from python'
 
M

Michel Claveau - abstraction méta-galactique non t

Hi !

But I had register Python from a long time ; and python-part(s) are...
ignored.
During this time, I continue my developments with COM...

@-salutations
 
M

Marcel van den Dungen

document.all["idspan"] = 'hello from python'
That should of course be:
document.all["idspan"].innerText = 'hello from python'

It turns out that Python was not registered as ActiveX scripting
language. I assumed that this was done by the PythonWin
installation program.

Its working now.

Thanks everyone for the help!
Marcel.
 
M

Michael P. Dubner

Only one fix: you can ever use:
<html>
<head>
<title>Python controlled HTML application</title>
<hta:application id="oApplication">
<script language="python">
def Onload():
alert('hello from python')
document.all["idspan"] = 'hello from python'

document.getElementById('idspan').innerHTML = 'hello from python'
document.all['idspan'].innerHTML = 'hello from python'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,209
Messages
2,571,088
Members
47,687
Latest member
IngridXxj

Latest Threads

Top