473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Python in HTAs

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
Jul 18 '05 #1
13 5461
On Sun, 2004-10-17 at 14:25 -0700, Marcel van den Dungen wrote:
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 | ro***@planetargon.com
* 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-----

Jul 18 '05 #2
On Sun, 2004-10-17 at 14:25 -0700, Marcel van den Dungen wrote:
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 | ro***@planetargon.com
* 503.351.4730 | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
****************************************/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQBBcutN0QaQZBaqXgwRAkysAKDY3gGNKSsgrGjUqpzrWP vlNfnocQCfaTrY
6AJyz9Ca/dZ3RlMdpl53iF4=
=q+jF
-----END PGP SIGNATURE-----

Jul 18 '05 #3
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.

Jul 18 '05 #4
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'


Jul 18 '05 #5
Robby Russell <ro***@planetargon.com> wrote in message news:<ma**************************************@pyt hon.org>...
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
Jul 18 '05 #6
Roger <Ro***@see.my.sig> wrote in message news:<jZ*********************@twister1.libero.it>. ..
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.
Jul 18 '05 #7
Marcel van den Dungen wrote:
Robby Russell <ro***@planetargon.com> wrote in message news:<ma**************************************@pyt hon.org>...
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

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.

Jul 18 '05 #8
m_********@yahoo.com (Marcel van den Dungen) wrote in message news:<98*************************@posting.google.c om>...
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).
Jul 18 '05 #9
In addition to Marcel's comment I found this:
http://www.python.org/windows/win32c...Scripting.html

AFAIK when you register Python in this way it can be used in the same
way as VBScript and JScript...
Jul 18 '05 #10

"Marcel van den Dungen" <m_********@yahoo.com> wrote in message news:98*************************@posting.google.co m...
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'
</script>
</head>
<body onload="Onload();">
<span id="idspan" ></span>
</body>
</html>

Could not find any example on Google either.

TIA,
Marcel

Jul 18 '05 #11
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
--
Michel Claveau


Jul 18 '05 #12
m_********@yahoo.com (Marcel van den Dungen) wrote in message news:<98*************************@posting.google.c om>...
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.
Jul 18 '05 #13
Only one fix: you can ever use:

gnu valued customer wrote:
<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'
</script>
</head>
<body onload="Onload();">
<span id="idspan" ></span>
</body>
</html>

Could not find any example on Google either.

TIA,
Marcel

--
Best regards,
Michael Dubner (dubnerm.at.mindless.com)
Brainbench MVP/HTML+JavaScript (http://www.brainbench.com)
PS: Sorry for my English

Jul 18 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Emile van Sebille | last post by:
QOTW: "If we get 2.3.3c1 out in early December, we could release 2.3.3 final before the end of the year, and start 2004 with a 100% bug-free codebase <wink>." -- Tim Peters "cjOr proWe vbCould...
0
by: Emile van Sebille | last post by:
QOTW: "Have you ever used the copy module? I am *not* a beginner, and have used it *once* (and I can't remember what for, either)." -- Michael Hudson "It will likely take a little practice...
0
by: Emile van Sebille | last post by:
QOTW (in the OS agnostic category): "There is a (very popular) Python package out there which exposes the win32 api. I'm not sure what it's called. (win32api? pythonwin? win32all?)" -- Francis...
8
by: Bryan Lynn | last post by:
I am looking to create a standard ASP.NET web application, but present it to the end user via a HTA. This will allow me to customize my own UI, do some cross domain scripting, and bypass some of...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.