PyOoHtml - Home --- Python Object Oriented HTML

ATTENTION!! This framework is useful only for smart developers!

> python tutorial.py 1

def main1():
	root = Node()
	
	# escape the text
	root.text("Escaped text: <b>Bold</b>")

	# does not escape the text
	root.html("<hr>Not escaped text: <b>Bold</b>")
		
	return root.toHtml()

> python tutorial.py 2

def main2():
	root = Node()
	
	# Inline and not inline text
	root.CODE().text("Text").text("Inline").text("Not_inline", inline=False)
	root.HR()
	
	# Using the TAG function inline()
	root.text("Text")
	# Not inline
	code = root.CODE()
	code.text("Not_inline")
	# Inline
	code = root.CODE()
	code.text("Inline")
	code.inline()
	# Not inline (parent.child --> root.code)
	root.CODE("Not_inline").child.inline(False)
	
	return root.toHtml()

> python tutorial.py 3

def main3():
	root = Node()
	
	# When the first argument is text, return the parent
	root.CODE("code").U("underline").text("text").B("bold").I("italic").HR()

	# When the first argument is not text, return self
	root.CODE().U("underline").A("link", {"href": "http://python.org"})
	root.HR()
	
	# When return the parent, child exists
	root.U("PARENT").child.CODE("underline").I("italic").text("text").B("bold")
	
	return root.toHtml()

> python tutorial.py 4

def main3():
	root = Node()
	
	# Attention, the first argument is text
	root.comment("This is a comment").text("See the generated HTML")
	
	# Now the first argument is not text
	comment = root.comment()
	comment.text("You can not see this text from your web browser")
	
	return root.toHtml()

> python tutorial.py 5

def main5():
	root = Node()
	
	# close tag
	root.HR()
	root.HR().open()
	root.HR("(inside)").child.inline(False)
	
	root.text(" See the generated HTML")
	
	return root.toHtml()

> python tutorial.py 6

def main5():
	root = Node()

	# See all supported TAGS
	root.B("TAGS: ")
	for t in TAGS:
		root.CODE().U(t.upper()).text(" ")
		
	return root.toHtml()

> python tutorial.py 7

def main7():
	root = Node()

	# tag function: name (mandatory), text (optional), attributes (optional)
	root.tag("a", "Link", {"href": "http://python.org"})
		
	return root.toHtml()

> python tutorial.py 8

def main8():
	root = Node()

	# selected option
	select = root.SELECT({"name": "select", "multiple": True})
	select.OPTION("Value 1", {"value": "val1"})
	select.OPTION("Value 2", {"value": "val2", "selected": True})
	
	return root.toHtml()

> python tutorial.py 9

def main9():
	root = Node()

	# using DIV
	div1 = root.DIV({"style": "border: 2px solid red; padding: 10px"})
	div2 = div1.DIV({"style": "border: 2px solid blue; padding: 10px"})
	div3 = div2.DIV({"style": "border: 2px solid green; padding: 10px"})
	
	return root.toHtml()