首页IT科技pyjamas是复数还是单数(pyjamas build AJAX apps in Python (like Google did for Java))

pyjamas是复数还是单数(pyjamas build AJAX apps in Python (like Google did for Java))

时间2025-08-03 08:30:11分类IT科技浏览5620
导读:Getting Started with...

Getting Started with

pyjamas

Programming with pyjamas needs a little bit of rethinking about

the way that you do Web application development. Primarily,

you need to forget virtually everything youve ever learned and

come to expect Web development to be. The reason for this is

very simple: Pyjamas is pure javascript. Although written

in python, not javascript, it is essential to bear in mind

that virtually 100% of your web application will be javascript -

not HTML. The programming style you may be accustomed to for

HTML programming involves placing as much HTML into one page

as you can stand, and making the minimum number of exceptions

and allowances for dynamic content that you can manage, without

making the HTML page "too complicated" to be readable.

Pyjamas makes it possible for you to break pages down into concepts.

classes. widgets. maybe some CSS styling is added, almost as an

afterthought, on top of the "real" functionality. In other words, Pyjamas

is actually more like Desktop application development than it is

Web development.

With that in mind, the best possible starting point has to be the

examples, most of which were ported from

Google Web Toolkit. They will make it really clear just how "not"

Web that pyjamas - and incidentally GWT - really are.

Examples

The simplest example is of course the traditional

Hello World

or, in this case, Hello AJAX. If youve downloaded pyjamas, you

will be able to browse, with your browser, to the examples directory

and see this in action for yourself. Type

"file://home/yourusername/pyjamas/examples" into your URL bar - or

wherever you have unpacked pyjamas to and continue to browse to

the helloworld output directory.

Once you have played with the example, online, try it on your local

machine. Remember to run the "build.sh" script (if you have linux

or MacOS, or execute python.exe ../../build/build.py Hello.py if

you have windows). Then, take a look at the source code

that generated it, which is shown here: from pyjamas import Window from pyjamas.ui import RootPanel, Button def greet(sender): Window.alert("Hello, AJAX!") b = Button("Click me", greet) RootPanel().add(b)

The most important thing to note is that everything gets added to

RootPanel. RootPanel() gives you access to the Browsers

DOM model (starting of course at body). To illustrate,

try adding this, and see what happens: RootPanel().add(HTML("Hello <b>World</b>"))

You should get nothing - and if you look in your Javascript

console for an error message, you should find an error indicating

that "HTML" does not exist. This is correct - because you needed to

add this to the top of the module, along with the other imports: from pyjamas.ui import HTML

Now if you re-run build.sh, you should see both a button and next

to it the words "Hello World

". Congratulations, youve just

successfully developed your first pyjamas application.
声明:本站所有文章                ,如无特殊说明或标注                        ,均为本站原创发布                。任何个人或组织        ,在未征得本站同意时                ,禁止复制                、盗用                        、采集        、发布本站内容到任何网站        、书籍等各类媒体平台                        。如若本站内容侵犯了原著者的合法权益                        ,可联系我们进行处理        。

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
amazon数据中心(如何在AmazonAurora中实现数据库的时间点恢复和数据还原) 进程的三个基本状态转换图(ati2sgag.exe进程安全吗 ati2sgag进程信息查询)