[Tutor] Overriding a function method(HTMLgen)
Tim Johnson
tim@johnsons-web.com
Sun Jan 19 21:35:11 2003
Hello All:
I am implementing the HTMLgen library. Very nice.
I am using the SimpleDocument object and wished
to insert internal css code with the object.
After looking at the code and experimenting with it, I
felt that it wasn't possible.
In HTMLgen.py at line 289, I found the following code:
if self.style:
s.append('\n<STYLE>\n<!--\n%s\n-->\n</style>\n' % self.style)
well, all that *seemed* to do (python newbie here) was insert a comment
tag.
I made the following change
s.append('\n<STYLE type="text/css">\n %s\n</style>\n' % string.join(self.style,'\n '))
which allows me to write an interface like this:
style=[
'a:visited { color:Darkred; text-decoration: none }',
'a:link { color:Darkred; text-decoration:none;}'
'a:hover { color:Darkred; text-decoration:underline; background-color: #EEDD82;}',
# etc, etc,
]
which is what I was looking for. Produced a <style tag with appropriate
css code.
The problem is, as I see it, I've broken Mr. Friedrich's code,
and there must be a more 'pythonic' way to do this than just
'hacking up' his code.
I'd appreciate an example or two..... or being pointed to
documentation on this (or both).
thanks.
--
Tim Johnson <tim@johnsons-web.com>
http://www.alaska-internet-solutions.com
http://www.johnsons-web.com