]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/wx/lib/ClickableHtmlWindow.py
reduce the number of objects for a quicker startup time
[wxWidgets.git] / wxPython / wx / lib / ClickableHtmlWindow.py
... / ...
CommitLineData
1# 12/01/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2#
3# o Updated for wx namespace. Not tested though.
4#
5# 12/17/2003 - Jeff Grimmett (grimmtooth@softhome.net)
6#
7# o Removed wx prefix from class name,
8# updated reverse renamer
9#
10
11"""
12sorry no documentation...
13Christopher J. Fama
14"""
15
16
17import wx
18import wx.html as html
19
20class PyClickableHtmlWindow(html.HtmlWindow):
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):
27 apply(html.HtmlWindow.__init__,(self,parent,ID),kw)
28
29 def OnLinkClicked(self,link):
30 self.link = wx.TextDataObject(link.GetHref())
31 if link.GetEvent().ShiftDown():
32 if wx.TheClipboard.Open():
33 wx.TheClipboard.SetData(self.link)
34 wx.TheClipboard.Close()
35 else:
36 dlg = wx.MessageDialog(self,"Couldn't open clipboard!\n",wx.OK)
37 wx.Bell()
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
57