2003-12-16 19:34:40 -05:00
|
|
|
# 12/01/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
|
|
|
#
|
|
|
|
# o Updated for wx namespace. Not tested though.
|
|
|
|
#
|
2003-12-18 14:10:26 -05:00
|
|
|
# 12/17/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
|
|
|
#
|
|
|
|
# o Removed wx prefix from class name,
|
|
|
|
# updated reverse renamer
|
|
|
|
#
|
2003-07-02 19:13:10 -04:00
|
|
|
|
2003-11-12 16:34:20 -05:00
|
|
|
"""
|
|
|
|
sorry no documentation...
|
|
|
|
Christopher J. Fama
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2003-12-16 19:34:40 -05:00
|
|
|
import wx
|
|
|
|
import wx.html as html
|
2003-11-12 16:34:20 -05:00
|
|
|
|
2003-12-18 14:10:26 -05:00
|
|
|
class PyClickableHtmlWindow(html.HtmlWindow):
|
2003-11-12 16:34:20 -05:00
|
|
|
"""
|
|
|
|
Class for a wxHtmlWindow which responds to clicks on links by opening a
|
|
|
|
browser pointed at that link, and to shift-clicks by copying the link
|
|
|
|
to the clipboard.
|
|
|
|
"""
|
|
|
|
def __init__(self,parent,ID,**kw):
|
2003-12-16 19:34:40 -05:00
|
|
|
apply(html.HtmlWindow.__init__,(self,parent,ID),kw)
|
2003-11-12 16:34:20 -05:00
|
|
|
|
|
|
|
def OnLinkClicked(self,link):
|
2003-12-16 19:34:40 -05:00
|
|
|
self.link = wx.TextDataObject(link.GetHref())
|
2003-11-12 16:34:20 -05:00
|
|
|
if link.GetEvent().ShiftDown():
|
2003-12-16 19:34:40 -05:00
|
|
|
if wx.TheClipboard.Open():
|
|
|
|
wx.TheClipboard.SetData(self.link)
|
|
|
|
wx.TheClipboard.Close()
|
2003-11-12 16:34:20 -05:00
|
|
|
else:
|
2003-12-16 19:34:40 -05:00
|
|
|
dlg = wx.MessageDialog(self,"Couldn't open clipboard!\n",wx.OK)
|
|
|
|
wx.Bell()
|
2003-11-12 16:34:20 -05:00
|
|
|
dlg.ShowModal()
|
|
|
|
dlg.Destroy()
|
|
|
|
else:
|
|
|
|
if 0: # Chris's original code...
|
|
|
|
if sys.platform not in ["windows",'nt'] :
|
|
|
|
#TODO: A MORE APPROPRIATE COMMAND LINE FOR Linux
|
|
|
|
#[or rather, non-Windows platforms... as of writing,
|
|
|
|
#this MEANS Linux, until wxPython for wxMac comes along...]
|
|
|
|
command = "/usr/bin/netscape"
|
|
|
|
else:
|
|
|
|
command = "start"
|
|
|
|
command = "%s \"%s\"" % (command,
|
|
|
|
self.link.GetText ())
|
|
|
|
os.system (command)
|
|
|
|
|
|
|
|
else: # My alternative
|
|
|
|
import webbrowser
|
|
|
|
webbrowser.open(link.GetHref())
|
|
|
|
|
2003-07-02 19:13:10 -04:00
|
|
|
|