Author: bugman Date: Thu Feb 4 18:01:49 2010 New Revision: 10647 URL: http://svn.gna.org/viewcvs/relax?rev=10647&view=rev Log: Added the relax website link and the long program description to the about relax widget. The method draw_wrapped_text() was added to handle both the licence text and the long description. Modified: branches/bieri_gui/gui_bieri/about.py Modified: branches/bieri_gui/gui_bieri/about.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/about.py?rev=10647&r1=10646&r2=10647&view=diff ============================================================================== --- branches/bieri_gui/gui_bieri/about.py (original) +++ branches/bieri_gui/gui_bieri/about.py Thu Feb 4 18:01:49 2010 @@ -168,7 +168,9 @@ self.draw_icon() self.draw_title() self.draw_description() + self.draw_link() self.draw_copyright() + self.draw_desc_long() self.draw_licence() @@ -191,6 +193,12 @@ self.offset(y2) + def draw_desc_long(self): + """Draw the long relax description.""" + + self.draw_wrapped_text(self.info.desc_long, spacer=10) + + def draw_description(self): """Draw the relax description text.""" @@ -221,17 +229,70 @@ def draw_licence(self): """Draw the relax licence text.""" + self.draw_wrapped_text(self.info.licence, spacer=10) + + + def draw_link(self): + """Draw the relax description text.""" + + # Set the font. + font = wx.Font(pointSize=11, family=wx.FONTFAMILY_ROMAN, style=wx.FONTSTYLE_ITALIC, weight=wx.NORMAL, underline=True) + self.dc.SetFont(font) + self.dc.SetTextForeground('#0017aa') + + # The text extent. + x, y = self.dc.GetTextExtent(self.info.website) + + # Draw the text, with a spacer. + text = self.dc.DrawText(self.info.website, self.boarder + (self.dim_x - x)/2, self.offset(17)) + + # Add the text extent. + self.offset(y) + + # Restore the old font colour (black). + self.dc.SetTextForeground('black') + + + def draw_title(self): + """Draw the relax title with name and version.""" + + # The text. + text = self.info.title + ' ' + self.info.version + + # Set the font. + font = wx.Font(14, wx.FONTFAMILY_ROMAN, wx.NORMAL, wx.NORMAL) + self.dc.SetFont(font) + + # The text extent. + x, y = self.dc.GetTextExtent(text) + + # Draw the text, with a spacer. + self.dc.DrawText(text, self.boarder + (self.dim_x - x)/2, self.offset(20)) + + # Add the text extent. + self.offset(y) + + + def draw_wrapped_text(self, text, spacer=10): + """Generic method for drawing wrapped text in the relax about widget. + + @param text: The text to wrap and draw. + @type text: str + @keyword spacer: The pixel width of the spacer to place above the text block. + @type spacer: int + """ + # Set the font. font = wx.Font(10, wx.FONTFAMILY_ROMAN, wx.NORMAL, wx.NORMAL) self.dc.SetFont(font) # Wrap the text. - lines = wrap(self.info.licence, 60) + lines = wrap(text, 60) # Find the max y extent. max_y = 0 for line in lines: - x, y = self.dc.GetTextExtent(self.info.desc) + x, y = self.dc.GetTextExtent(text) if y > max_y: max_y = y @@ -245,26 +306,6 @@ # Update the offset. self.offset(max_y + 1) - - - def draw_title(self): - """Draw the relax title with name and version.""" - - # The text. - text = self.info.title + ' ' + self.info.version - - # Set the font. - font = wx.Font(14, wx.FONTFAMILY_ROMAN, wx.NORMAL, wx.NORMAL) - self.dc.SetFont(font) - - # The text extent. - x, y = self.dc.GetTextExtent(text) - - # Draw the text, with a spacer. - self.dc.DrawText(text, self.boarder + (self.dim_x - x)/2, self.offset(20)) - - # Add the text extent. - self.offset(y) def offset(self, val=0):