import wx
def SomeListener(evt):
print "Got Event:",evt
print "My XY:",evt.GetX(),evt.GetY()
#youll have to figure out which word you clicked using x,y (note x,y relative to static text field)
a= wx.App(redirect=False)
f = wx.Frame(None,-1)
p = wx.Panel(f,-1)
t = wx.StaticText(p,-1,"Some Text")
t.Bind(wx.EVT_LEFT_DOWN,SomeListener)
f.Show()
a.MainLoop()
またはhtmlwinを使用しています...しかし、すべての単語に下線が引かれています...そうしない方法を理解できませんでした
import wx
import wx.html
def OnClickWord(e):
print "You Clicked:",e.GetLinkInfo().GetHref()
return
class MyHtmlFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title)
html = wx.html.HtmlWindow(self)
#if "gtk2" in wx.PlatformInfo:
html.SetStandardFonts()
html.SetPage(
"<style>a {text-decoration: none;color: #000; }</style>" #sorry no css support :/
"<a href=\"word1\">Word1</a> <a href=\"word2\">word 2</a> <a href=\"wizard of oz\">wizard of oz</a>.")
app = wx.PySimpleApp()
frm = MyHtmlFrame(None, "Simple HTML")
frm.Bind(wx.html.EVT_HTML_LINK_CLICKED,OnClickWord)
frm.Show()
app.MainLoop()