Reputation: 945
Is it possible to embed Gecko in Python so that I can display HTML documents. And then possibly create custom Javascript bindings so that, I can call my own Javascript functions in the HTML document that will do some task that are not normally allowed in the browser, like making system calls. This will be done by the underlying python program.
Upvotes: 1
Views: 2066
Reputation: 1668
There are a variety of ways to do this, actually. First, are you using another GUI library (e.g. wxPython, Tkinter, PyGTK, etc.) and you want to embed Gekco into a window that you create in one of those frameworks? i.e. Are you trying to embed a Gecko frame into a Tkinter (or wxPython, or PyGTK, or...) window?
Is using ONLY Gecko for the GUI a viable alternative? If so, you might want to take a look at XUL (and xulrunner). Gecko can interface with the outside world via XPCOM, and there is some integration of Python with XPCOM (see pythonext at Google Code). So, it's possible to write a mixed application where the UI elements are described in XUL with active javascript and signals are sent to/from the UI and your python code (which runs locally and can execute arbitrary system calls, etc.)
Along the same lines, but somewhat more straightforward, you can create a python script that launches a xulrunner app AND a locally running webserver. The xulrunner app hosts the GUI, along with active javascript code, while your locally running webserver executes arbitrary python code (including local system calls). I've used the ("batteries included") BaseHTTPServer many times to do something similar and I'm confident that you'll find it relatively straightforward to do so.
Upvotes: 1