#!/usr/bin/env python2
from eagle import *
# Must be alive when using, so put in img_test until the end of application
img_test = Image(id="test", filename="test.png")
def img_provider(filename):
if filename.startswith("myapp://"):
data = chr(127) * 22 * 22 * 3
return Image(data=data, width=22, height=22)
def clear(app, button):
app["richtext"].set_text("")
def append(app, button):
app["richtext"].append("
another paragraph!
")
App(title="Rich Text Example",
center=(RichText(id="richtext",
img_provider=img_provider,
text="""\
level 1 header
level 2 header
level 3 header
Here is a paragraph, followed by horizontal rule
Left-aligned text
Centered text
Right-aligned text
Justified text filling the whole horizontal space.
Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc
Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc
Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc
Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc
Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc
Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc Abc
List of styles:
- bold
- italic
- serif font
- red fore, blue background






- other numbered list item
- other numbered list item
external url
go to end of this page
# we also support pre formatted text:
def function(arg0, arg1, *args, **kargs):
print "arg0:", arg0
print "arg1:", arg1
print "args:", args
print "kargs:", kargs
end of page
"""
),
),
bottom=(
Button(id="clear", stock="clear", callback=clear),
Button(id="append", stock="add", callback=append),
)
)
run()