Возможно ли это, или есть библиотека, которая позволит мне анализировать HTML-код внутри виджета wx.TextCtrl?
Конечно, просто используйте myTextCtrl.GetValue(), а затем проанализируйте строку с чем-то вроде BeautifulSoup, xml.dom.minidom, HTMLParser и т. Д .:
myTextCtrl.GetValue()
BeautifulSoup
xml.dom.minidom
HTMLParser
from BeautifulSoup import BeautifulSoup # lets say this is the text inside the TextCtrl: # '<html><head><title>Page title</title></head><body><p id="firstpara" align="center">This is paragraph <b>one</b>.<p id="secondpara" align="blah">This is paragraph <b>two</b>.</html>' # htmlStr = myTextCtrl.GetValue() soup = BeautifulSoup(htmlStr) soup.contents[0].name # u'html' soup.contents[0].contents[0].name # u'head' head = soup.contents[0].contents[0] head.parent.name # u'html' head.next # <title>Page title</title> head.nextSibling.name # u'body' head.nextSibling.contents[0] # <p id="firstpara" align="center">This is paragraph <b>one</b>.</p> head.nextSibling.contents[0].nextSibling # <p id="secondpara" align="blah">This is paragraph <b>two</b>.</p>
wxTextCtrl отобразит HTML со всеми тегами
<html><body>Hello, world!</body></html>");
Чтобы отобразить html, вам нужно использовать wxHtmlWindow
w = wxHtmlWindow(this) w.SetPage("<html><body>Hello, world!</body></html>")