import testopt
import time
import pyui
text ="""
<HTML>
<HEAD>
<TITLE> PyUI HTML Panel Test </TITLE>
</HEAD>
<BODY bgColor="#ffffd0" text="#000000">
<H1 color=#ff0000> PyUI HTML Test </H1>
<p>Some regular " text in a normal font here. This should be
<b>bold</b> but the rest of this should be normal text.</p>
<img src="max.bmp"> <b>some text here <i>between the two images<img src="max.bmp" width=50 height=50>
<h2> Heading Two </h2>
</i>
<p color="#000055">Menus are instances of the class widgets.Menu. They have menu
items added to them with the addItem() method. The addItem method
takes a title, a <a href="http://www.news.com">handler method</a> and possibly a sub-menu. The <a>handler
method will be called with the menuItem instance as the argument.
The sub-menu <font color="#bb0000" face="arial" >argument can be used to add</font> sub-menu </a>to the menu
allowing hierarchies of menus.</p>
<pre>
Pre-formatted text:
class PyuiHTMLParser(HTMLParser):
def __init__(self, "panel"):
self.panel = panel
def handle_starttag(self, "tag", attrs):
self.panel.handle_starttag(tag, attrs)
</pre>
<p> Below is a list of elements</p>
<OL>
<li> List item 1 </li>
<li> List item 2 </li>
<li> List item 3 </li>
<li> List item 4 </li>
<li> A very long List item goes here. </li>
</OL>
<p> Below is a horizontal line </p>
<HR>
<p color=#00ff00>Menus are instances of the class widgets.Menu. They have menu
items added to them with the addItem() method. The addItem method
takes a title, a handler method and possibly a sub-menu. The handler
method will be called with the menuItem instance as the argument.
The sub-menu argument can be used to add sub-menu to the menu
allowing hierarchies of menus.</p>
<img src="max.bmp" width=400 height=100>
<p>Menus are instances of the class widgets.Menu. They have menu
items added to them with the addItem() method. The addItem method
takes a title, a handler method and possibly a sub-menu. The handler
method will be called with the menuItem instance as the argument.
The sub-menu argument can be used to add sub-menu to the menu
allowing hierarchies of menus.</p>
<p>Menus are instances of the class widgets.Menu. They have menu
items added to them with the addItem() method. The addItem method
takes a title, a handler method and possibly a sub-menu. The handler
method will be called with the menuItem instance as the argument.
The sub-menu argument can be used to add sub-menu to the menu
allowing hierarchies of menus.</p>
<HR>
<p> Bottom of the page </p>
</BODY>
</HTML>
"""
def onbutton(self):
print "got a button "
def run():
opts = testopt.parseCommandLine(1024, 768)
done = 1
frame = 0
t = time.time()
pyui.init(*opts)
w = pyui.widgets.Frame(0,0,800,600, "HTML!")
h = pyui.html.HTMLPanel()
w.replacePanel(h)
w.pack()
#f = open('C:/ninja/Projects/pyui/website/index.html')
#text = f.read()
#f.close()
h.feed(text)
#h.feed(testText)
w.resize(800,600)
pyui.run()
print "done"
pyui.quit()
if __name__ == '__main__':
run()
|