]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/wx/lib/ClickableHtmlWindow.py
Added wxAutoNSAutoreleasePool to Create(Tool|Status)Bar
[wxWidgets.git] / wxPython / wx / lib / ClickableHtmlWindow.py
index 9275ca00455cc911c3a40418f71d7acd72d24ca3..372f7d1057a50c2962749b0f255843ff31707b69 100644 (file)
@@ -1,8 +1,49 @@
 
-"""Renamer stub: provides a way to drop the wx prefix from wxPython objects."""
+"""
+sorry no documentation...
+Christopher J. Fama
+"""
+
+
+
+from wxPython.wx import *
+from wxPython.html import *
+
+class wxPyClickableHtmlWindow(wxHtmlWindow):
+    """
+    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):
+        apply(wxHtmlWindow.__init__,(self,parent,ID),kw)
+
+    def OnLinkClicked(self,link):
+        self.link = wxTextDataObject(link.GetHref())
+        if link.GetEvent().ShiftDown():
+            if wxTheClipboard.Open():
+                wxTheClipboard.SetData(self.link)
+                wxTheClipboard.Close()
+            else:
+                dlg = wxMessageDialog(self,"Couldn't open clipboard!\n",wxOK)
+                wxBell()
+                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())
+
 
-from wx import _rename
-from wxPython.lib import ClickableHtmlWindow
-_rename(globals(), ClickableHtmlWindow.__dict__, modulename='lib.ClickableHtmlWindow')
-del ClickableHtmlWindow
-del _rename