]>
Commit | Line | Data |
---|---|---|
b881fc78 RD |
1 | # 12/01/2003 - Jeff Grimmett (grimmtooth@softhome.net) |
2 | # | |
3 | # o Updated for wx namespace. Not tested though. | |
4 | # | |
1fded56b | 5 | |
d14a1e28 RD |
6 | """ |
7 | sorry no documentation... | |
8 | Christopher J. Fama | |
9 | """ | |
10 | ||
11 | ||
b881fc78 RD |
12 | import wx |
13 | import wx.html as html | |
d14a1e28 | 14 | |
b881fc78 | 15 | class wxPyClickableHtmlWindow(html.HtmlWindow): |
d14a1e28 RD |
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): | |
b881fc78 | 22 | apply(html.HtmlWindow.__init__,(self,parent,ID),kw) |
d14a1e28 RD |
23 | |
24 | def OnLinkClicked(self,link): | |
b881fc78 | 25 | self.link = wx.TextDataObject(link.GetHref()) |
d14a1e28 | 26 | if link.GetEvent().ShiftDown(): |
b881fc78 RD |
27 | if wx.TheClipboard.Open(): |
28 | wx.TheClipboard.SetData(self.link) | |
29 | wx.TheClipboard.Close() | |
d14a1e28 | 30 | else: |
b881fc78 RD |
31 | dlg = wx.MessageDialog(self,"Couldn't open clipboard!\n",wx.OK) |
32 | wx.Bell() | |
d14a1e28 RD |
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 | ||
1fded56b | 52 |