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