Can I use python in html to call functions in other libs? #544

tempbeta opened this Issue Mar 15, 2013 · 8 comments


None yet

6 participants


I want to use python as a glue language to call DLLs, shared libraries,etc.
I tried this:

<script type="text/python" src="py/"></script>
<button onClick="foo()">test</button>

def foo():
    windll.user32.MessageBoxA(0, 'test','show',  0)

It didn't work for me,but it works in TideSDK.
Any where wrong?Or there are some security limits?


node-webkit allows you to call nodejs modules and javascript not python.
In other words, node-webkit doesn't support python.


thank you sbspk
I tried IronPython to do it:


<script src="js/dlr-latest.js" type="text/javascript"></script>
<script type="application/x-python">
import sys
sys.path.append ("py/Lib")
import ctypes

it works but can't import modules like ctypes:
ImportError: No module named ctypes
What should I do?

Maybe I should try node-ffi


I can't find any bindings allowing direct communication between node-flavored javascript and python.

Firstly, I'm going to throw in the customary "why would you even do that?"

However, if you really do need this to work, consider writing a wrapper for your python script which creates an API on a localhost-bound port or socket. Then, launch the python script from your node-webkit application and communicate with it via that socket.


@sonicsnes sounds like a good idea.I will try it.


May I ask what you need python for? Nothing against Python, but what can't you do in JS that you can do in Python? Or is something already built.

If it's something already done, you could try... or something like that.

Even then the point of node-webkit is multiplatform webkit based gui. Adding python would remove support for Windows/maybe Mac depending on what you need. You'd need to hack together some sort of solution for those.

Moral of the story is, it sounds like way too much work.


I think nodejs is as powerful as python. nodejs is enough.
I also can run python as a child process. I think it is easy to implement.


@dubcanada I need python to call Win32API (with ctypes),I found JS can do it only with node-ffi(AFAIK) ,It's going to take a little bit more work for me.

nwjs member

hello, we don't support python directly in the DOM.

@rogerwang rogerwang closed this May 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment