Last active
September 7, 2017 17:46
-
-
Save pavoljuhas/806c559313145a8ac82d80c0d33b2436 to your computer and use it in GitHub Desktop.
example of wx.TextCtrl with a hyperlink
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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