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