]> git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/lib/ClickableHtmlWindow.py
Fixed a very weird typo
[wxWidgets.git] / wxPython / wx / lib / ClickableHtmlWindow.py
1 # 12/01/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2 #
3 # o Updated for wx namespace. Not tested though.
4 #
5
6 """
7 sorry no documentation...
8 Christopher J. Fama
9 """
10
11
12 import wx
13 import wx.html as html
14
15 class wxPyClickableHtmlWindow(html.HtmlWindow):
16 """
17 Class for a wxHtmlWindow which responds to clicks on links by opening a
18 browser pointed at that link, and to shift-clicks by copying the link
19 to the clipboard.
20 """
21 def __init__(self,parent,ID,**kw):
22 apply(html.HtmlWindow.__init__,(self,parent,ID),kw)
23
24 def OnLinkClicked(self,link):
25 self.link = wx.TextDataObject(link.GetHref())
26 if link.GetEvent().ShiftDown():
27 if wx.TheClipboard.Open():
28 wx.TheClipboard.SetData(self.link)
29 wx.TheClipboard.Close()
30 else:
31 dlg = wx.MessageDialog(self,"Couldn't open clipboard!\n",wx.OK)
32 wx.Bell()
33 dlg.ShowModal()
34 dlg.Destroy()
35 else:
36 if 0: # Chris's original code...
37 if sys.platform not in ["windows",'nt'] :
38 #TODO: A MORE APPROPRIATE COMMAND LINE FOR Linux
39 #[or rather, non-Windows platforms... as of writing,
40 #this MEANS Linux, until wxPython for wxMac comes along...]
41 command = "/usr/bin/netscape"
42 else:
43 command = "start"
44 command = "%s \"%s\"" % (command,
45 self.link.GetText ())
46 os.system (command)
47
48 else: # My alternative
49 import webbrowser
50 webbrowser.open(link.GetHref())
51
52