wxPython htmlWindow <textarea>无法正常工作</textarea>

时间:2013-07-12 18:21:48

标签: python html window wxpython

我正在使用wx.html.htmlWindow编写一个简单的程序,我遇到了一个问题:当我尝试渲染<textarea></textarea>时,它没有被显示!我做错了吗?

代码:

import wx
import wx.html

class MyHtmlFrame(wx.Frame):

    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1)
        self.html = wx.html.HtmlWindow(self)
        if "gtk2" in wx.PlatformInfo:
            self.html.SetStandardFonts()
        self.html.SetPage("""<html>
<head>
<title>Test</title>
</head>

<body>
<h1>Header</h1>

<textarea></textarea>
</body>
</html>""")
        self.Show()

app = wx.App(False)
HTML = MyHtmlFrame(None)
app.MainLoop()

N.B: 当我使用<textarea>尝试wx.html2.WebView时,它没有任何问题。

1 个答案:

答案 0 :(得分:1)

<textarea>元素应驻留在<form>元素中,或者公开form属性(在HTML5中)。请参阅Can You Use <textarea> Outside the Scope of a <form>

由于<textarea>元素不在<form>中,我强烈怀疑HTML渲染器会忽略它。

尝试:

<body>
<h1>Header</h1>

<form>
<textarea></textarea>
</form>
</body>