Skip to content

Instantly share code, notes, and snippets.

@pavoljuhas
Last active September 7, 2017 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavoljuhas/806c559313145a8ac82d80c0d33b2436 to your computer and use it in GitHub Desktop.
Save pavoljuhas/806c559313145a8ac82d80c0d33b2436 to your computer and use it in GitHub Desktop.
example of wx.TextCtrl with a hyperlink
#!/usr/bin/env python
import re
import wx.html
import webbrowser
msg = """
<p>
PDFgui has encountered a problem. We are sorry for the inconvenience.
</p><p>
You can view current bug reports and feature requests at
<a href="https://github.com/diffpy/diffpy.pdfgui/issues">
https://github.com/diffpy/diffpy.pdfgui/issues</a>.
</p><p>
Discuss PDFgui and learn about new developments and features at
<a href="https://groups.google.com/d/forum/diffpy-users">
https://groups.google.com/d/forum/diffpy-users</a>.
</p>
""".strip()
class MyFrame(wx.Frame):
""" We simply derive a new class of Frame. """
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title=title, size=(500,400))
self.label_header = wx.html.HtmlWindow(self, style=wx.TE_READONLY |
wx.TE_MULTILINE | wx.TE_NO_VSCROLL | wx.BORDER_NONE)
self.label_header.SetPage(msg)
self.label_header.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.onURL)
self.Show(True)
def onURL(self, evt):
link = evt.GetLinkInfo()
webbrowser.open(link.GetHref())
return
app = wx.App(False)
frame = MyFrame(None, "Problem Report for PDFgui")
app.MainLoop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment