Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5612424
  • 博文数量: 922
  • 博客积分: 19333
  • 博客等级: 上将
  • 技术积分: 11226
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-27 14:33
文章分类

全部博文(922)

文章存档

2023年(1)

2020年(2)

2019年(1)

2017年(1)

2016年(3)

2015年(10)

2014年(17)

2013年(49)

2012年(291)

2011年(266)

2010年(95)

2009年(54)

2008年(132)

分类: Python/Ruby

2012-03-26 10:32:36



Code your webpage like a GUI!

PyH allows you to simply generate HTML pages from within your python code in an object-oriented fashion. Each HTML tag is an object that can be modified at any time. The HTML tags are neatly output so that the sources of your HTML files are human-readable. Check the for documentation.

File bug reports and feature requests at

Get PyH

Download the latest version of pyh from the Download tab or directly from here

Quick example

The following python code snipet

from pyh import *
page
= PyH('My wonderful PyH page')
page
.addCSS('myStylesheet1.css', 'myStylesheet2.css')
page
.addJS('myJavascript1.js', 'myJavascript2.js')
page
<< h1('My big title', cl='center')
page
<< div(cl='myCSSclass1 myCSSclass2', id='myDiv1') << p('I love PyH!', id='myP1')
mydiv2
= page << div(id='myDiv2')
mydiv2
<< h2('A smaller title') + p('Followed by a paragraph.')
page
<< div(id='myDiv3')
page
.myDiv3.attributes['cl'] = 'myCSSclass3'
page
.myDiv3 << p('Another paragraph')
page
.printOut()

will generate the following html


lang="en" xmlns="">

</span><span class="pln">My wonderful PyH page</span><span class="tag">
href="myStylesheet1.css" type="text/css" rel="stylesheet" />
href="myStylesheet2.css" type="text/css" rel="stylesheet" />
src="myJavascript1.js" type="text/javascript">
src="myJavascript2.js" type="text/javascript">


class="center">My big title
id="myDiv1" class="myCSSclass1 myCSSclass2">
id="myP1">I love PyH!



id="myDiv2">

A smaller title


Followed by a paragraph.



id="myDiv3" class="myCSSclass3">

Another paragraph




PyH stands for any of the following : Pour yourself a ScotcH, Poor young Hobo or Peel your HTML. Any other suggestions?


阅读(6410) | 评论(0) | 转发(0) |
0

上一篇:互相

下一篇:一个生成html页面的python例子

给主人留下些什么吧!~~