From: Tom S. <tom...@li...> - 2001-01-07 16:12:13
|
Last week I played a little bit with "themeable classes". Today I looked at the Webware Code to see what one has to change to make that happen all over the place. Because the changes are real minimal I thought this could be interesting forWebware itself. Before you start reading further, look at this pictures to see the results ( http://www.python.de/webware/theme1.jpg http://www.python.de/webware/theme2.jpg http://www.python.de/webware/theme3.jpg http://www.python.de/webware/theme4.jpg http://www.python.de/webware/theme5.jpg http://www.python.de/webware/theme6.jpg That's what I changed: (http://www.python.de/webware/webwarethemes.zip contains the changes an the themes.) ---------------------------- In SidebarPage.py I added a constructor and a stylesheet reference. All other code is just putting some class="" instead of hardcoded colors (I reformatted the code a little bit for this mail, which is not cecessary If you make the changes yourself in the code) def __init__(self): Page.__init__(self) self.theme = 0 def writeHeader(self): self.writeln(''' <head> <title>%s</title> <link rel="STYLESHEET" type="text/css" href="styles/%s.css"> </head> <body %s>''' % ( self.title(), self.theme, self.htBodyArgs())) def writeBody(self): ... # sidebar wr('<tr> <td valign=top class=dark>') self.writeSidebar() wr('</td>') ... def writeBanner(self): # header title = self.title() #this hardcoded fonts are bad, but I did not chage them for now.. startFont1 = '<font face="Tahoma, Arial, Helvetica, sans-serif" size=+1 class=lightfont>' endFont1 = '</font>' startFont2 = '<font face="Tahoma, Arial, Helvetica, sans-serif" size=+2 class=lightfont><b>' endFont2 = '</b></font>' cornerTitle = self.cornerTitle() self.writeln(''' <tr> <td align=center class=verydark>%(startFont1)s%(cornerTitle)s%(endFont1)s</td> <td align=center class=mediumdark colspan=2> <br>%(startFont2)s%(title)s%(endFont2)s<br> </td> </tr>''' % locals()) def startMenu(self): # width=175, you do not nee this construction with a GIF image self.writeln('<table border=0 cellpadding=0 cellspacing=4 width=175><tr><td><font face=Arial size=-1>') self._wroteHeading = 0 --------------------------------- In ExamplePage.py I added a awake function (maybe this is not the right place?) def awake(self, transaction): SidebarPage.awake(self, transaction) req = self.request() if req.hasField('theme'): self.theme = req.field('theme') else: self.theme = 0 --------------------------------- With e.g http://localhost/wpy/Examples/Welcome?theme=6 http://localhost/wpy/Examples/Welcome?theme=3 you can change the themes. The Links in the Example directory do not have ?theme= appended, but making this change would be easy. comments welcome and I hope you like the proposed changes :-) -- Tom Schwaller http://www.linux-community.de |