适用于Python的NPAPI - Chrome扩展 [英] NPAPI for Python - Chrome Extension

查看:185
本文介绍了适用于Python的NPAPI - Chrome扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图开发一个chrome扩展,其中我编写了'python'中的所有
逻辑。现在在浏览器动作中,我想传递参数
并执行该.py文件并将结果返回给弹出窗口,这将在浏览器动作中打开
。从JavaScript调用.py文件我知道我会
需要编写一个NPAPI插件。但是我对b $ b应该采用哪种方法感到困惑。我遇到过很多选择,并且试图选择
是最简单的方法。


  1. Pyjamas Python Javascript编译器:是一个Python-to-Javascript
    编译器,它可以作为语言翻译工具,但常见问题解答中有
    网站最后一个问题,表明它不能在Chrome上运行。 ( http://pyjs.org/


  2. < FireBreath:FireBreath是一个框架,可以轻松创建
    强大的浏览器插件。 ( http://www.firebreath.org


  3. pyplugin - 用于XULRunner的Python NPAPI插件:它允许您
    使用XUL和Python构建跨平台的图形用户界面。
    http://pyplugin.com


  4. ol>

    Plz引导我以最简单的方式让我传递参数,
    执行.py文件并从.py获得返回的结果。



    Thanx

    解决方案

    好了,睡衣Python Javascript编译器不会完整 - 并非所有的python功能在JavaScript中可用,所以不可能将所有python转换为javascript。这可能会也可能不会做你想做的,但我不认为它发生在飞行中,我认为你必须在桌面上写东西,并通过编译器运行它,以获得另一侧的JavaScript。

    FireBreath是有史以来最令人惊叹的事情 - 我自从写完以后就知道了 - 它绝对会让你做你想做的事,但是你必须知道如何使用C ++绑定Python,才能做到你想要的。也就是说,你可以使用boost.python,它包含在FireBreath自带的boost子集中,但我从来没有用过,所以我不知道。使用NPAPI插件你几乎可以做任何事情,但是你需要真正小心安全问题。



    快速浏览pyplugin使它看起来像pyplugin基本上你会在FireBreath中写入,但只是一个原始的npapi插件。如果这能做到你想要的,那可能是最简单的方法。它旨在与XUL一起使用,这可能是一个问题,因为Chrome不支持XUL。你也可以修改它(因为它是GPL)来做你想做的事情。当然,如果你不打算发布你的源代码,那也可能是一个问题。



    解决你的问题最快捷的方法是什么?那么,你必须决定;它需要更多的研究,但我希望这足以让你开始。祝你好运!


    I am trying to develop a chrome extension in which i have coded all my logic in 'python' . Now on browser action i want to pass parameters and execute that .py file and return results to popup which will open on browser action. To call a .py file from JavaScript i know i will need to code a NPAPI plugin. But am confused between which approach i should take. I have come across few options and am trying to choose the easiest way to do it ..

    1. Pyjamas Python Javascript Compiler : is a Python-to-Javascript compiler which works as a language translator but on FAQ's of there site last question suggest it will not run on Chrome. ( http://pyjs.org/)

    2. FireBreath : FireBreath is a framework that allows easy creation of powerful browser plugins. ( http://www.firebreath.org )

    3. pyplugin - Python NPAPI plugin for XULRunner : It allows you to build cross-platform graphical user interfaces using XUL and Python. ( http://pyplugin.com )

    Plz Guide me to easiest way which will allow me to pass parameters and execute that .py file and receive returned results from .py.

    Thanx

    解决方案

    Well, Pyjamas Python Javascript Compiler will not be complete -- not all python features are available in javascript, so it's impossible to convert all python to javascript. This may or may not do what you want, but I don't think it happens "on the fly", I think you have to write things on the desktop and run it through the "compiler" to get javascript out the other side.

    FireBreath is the most awesomely amazing thing to ever hit the Internet -- I should know since I wrote it -- and it will absolutely allow you to do what you want, but you'll have to know how to tie into Python with C++ in order to do what you want. That said, you could probably use boost.python, which is included in the subset of boost that comes with FireBreath, but I've never used it so I don't know. You can pretty much do anything you want with an NPAPI plugin but you'll want to be real careful of security concerns.

    A quick glance at pyplugin makes it look like pyplugin is basically what you'd be writing in FireBreath, but just a raw npapi plugin. If this will do what you want, it's probably the easiest way to go. It's designed to be used with XUL, which may be a problem since Chrome doesn't support XUL. You might also be able to modify it (since it's GPL) to do what you want. Of course, if you weren't planning to release your source, that could also be a problem.

    The quickest way to solve your problem? Well, you'll have to decide; it'll take some more research, but I hope this is enough to at least get you started. Good luck!

    这篇关于适用于Python的NPAPI - Chrome扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆