zoukankan      html  css  js  c++  java
  • Pyjs Python Javascript Compiler, Desktop Widget Set and RIA Web Framework

    Pyjs - Python Javascript Compiler, Desktop Widget Set and RIA Web Framework

    Overview

    Like GWT, Pyjs translates a Python application and
    libraries
    (including UI widgets and DOM classes) into a
    Javascript application and libraries,
    and packages it all up:

    Overview of Pyjs' components

    1. pyjs translates Python code to Javascript by walking
      the Python abstract syntax tree and generating Javascript.
    2. pyjslib takes care of Python types that require
      a custom Javascript implementation for pyjs to work. For example,
      even though Python lists are similar to Javascript arrays, Python
      lists are converted to custom objects that implement methods such
      as append.
    3. UI widgets and a DOM library are provided as a
      convenience. They are written in Python and, like everything else,
      they are translated to Javascript for deployment. These are based
      on those in GWT.
    4. build manages the overall translation of
      individual components and creates a set of .html
      and .js files that can be served up by a Web server.

    Hello World

    The omnipresent hello world example, let's call it 'Hello Pyjs':

    from pyjamas.ui.RootPanel import RootPanel
    from pyjamas.ui.Label import Label
    
    l = Label('Hello Pyjs')
    RootPanel().add(l)
    

    Now run pyjsbuild hello.py to generate a plain Javascript
    application: pyjs creates an ./output folder containing all files
    you need to move to your webspace later. Of course you can test locally,
    too.

    Add 3 additional lines in total and your application can run with both
    Pyjs (i.e. plain Javascript) and Pyjs Desktop:

    import pyjd # this is dummy in pyjs
    from pyjamas.ui.RootPanel import RootPanel
    from pyjamas.ui.Label import Label
    
    pyjd.setup('public/hello.html')
    l = Label('Hello Pyjs')
    RootPanel().add(l)
    pyjd.run()
    

    Execute pyjd hello.py, or python hello.py, to run
    the very same application native on Python, giving you a Python stack trace on
    errors. Pyjs Desktop gives you much more control making testing and debugging
    a piece of a cake. No more web development pain – hooray!  
    Note the hello.html file referenced above: this is a container
    for your application generated by Pyjs that you can adjust to your needs.

  • 相关阅读:
    CF920E 补图强连通分量 BFS+set维护
    hdoj5876 补图最短路 BFS+set维护还可以更新的点.
    LA4287 tarjan求强连通分量+缩点
    cf920F SUM and REPLACE 树状数组+set 维护
    cf920G List Of Integers 二分+容斥
    cf 919D substring
    2017寒假概率dp训练题
    O(n)求数组中第k大的元素——堆排序
    O(n)求数组中第k大的元素——快排划分
    Turtlebot3入门手册之八:Realsense r200安装与测试
  • 原文地址:https://www.cnblogs.com/lexus/p/2495321.html
Copyright © 2011-2022 走看看