Author: bugman Date: Wed Sep 15 20:27:03 2010 New Revision: 11569 URL: http://svn.gna.org/viewcvs/relax?rev=11569&view=rev Log: The reference window is now fully functional. The back and forward buttons are removed and now links are opened in an external webbrowser. Modified: branches/bieri_gui/gui_bieri/references.py Modified: branches/bieri_gui/gui_bieri/references.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/references.py?rev=11569&r1=11568&r2=11569&view=diff ============================================================================== --- branches/bieri_gui/gui_bieri/references.py (original) +++ branches/bieri_gui/gui_bieri/references.py Wed Sep 15 20:27:03 2010 @@ -24,6 +24,7 @@ """The relax related references window.""" # Python module imports. +import webbrowser import wx import wx.html @@ -76,15 +77,24 @@ self.SetSizer(box) # Add some buttons. - self.add_buttons(box) + #self.add_buttons(box) # The HTML window. - self.html = wx.html.HtmlWindow(self, -1, size=(500, -1)) + self.html = RefWindow(self, -1, size=(500, -1)) box.Add(self.html, 1, wx.GROW) + + # Catch clicks. + self.Bind(wx.EVT_LEFT_DOWN, self.process_click) + + # Centre the window. + self.Centre() # Show the front page. self.front_page() + + def process_click(self): + pass def add_buttons(self, box): """Add forwards, backwards, and close buttons. @@ -182,3 +192,14 @@ # The footer. text = text + HTML_FOOTER self.html.SetPage(text) + + + +class RefWindow(wx.html.HtmlWindow): + """New HTML window class to catch clicks on links and open in a browser.""" + + def OnLinkClicked(self, url): + """Redefine the link clicking behaviour.""" + + # Open a new browser window instead. + webbrowser.open(url.GetHref())