wxHtmlWindow from XRC loaded as wxScrolledWindow

When trying to load a wxHtmlWindow from an XML resource file, the object returned is instead of the type wxScrolledWindow and therefore doesn't support SetPage and other html methods.

Although wxHtmlWindow is a desendant of wxScrolledWindow, what's the logic of returning a wxScrolledWindow when I am telling XRC to load wxHtmlWindow? Is this a bug?

Another silly question: how do I get the wxHtmlWindow control to display a paragraph in wrapped form instead one line per paragraph? I set the window style to wx.html.HW_DEFAULT_STYLE, and then have to scroll horizontally to see the complete text.

Thanks.

Hong Yuan

Hong Yaun wrote:

When trying to load a wxHtmlWindow from an XML resource file, the object returned is instead of the type wxScrolledWindow and therefore doesn't support SetPage and other html methods.

Although wxHtmlWindow is a desendant of wxScrolledWindow, what's the logic of returning a wxScrolledWindow when I am telling XRC to load wxHtmlWindow? Is this a bug?

No, in order for the OOR code to be able to give you an object of type wxHtmlWindow it has to know about the type. So I'm guessing that you havn't imported the wx.html module and so OOR doesn't know about the type and so looks at the parent class. Since it does know about wxScrolledWindow that is what it gives you. Try adding a "import wx.html" in your code.

Another silly question: how do I get the wxHtmlWindow control to display a paragraph in wrapped form instead one line per paragraph? I set the window style to wx.html.HW_DEFAULT_STYLE, and then have to scroll horizontally to see the complete text.

It should do so automatically. What else is on the page? What tags are used for that block of text?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Hong Yaun wrote:

When trying to load a wxHtmlWindow from an XML resource file, the object returned is instead of the type wxScrolledWindow and therefore doesn't support SetPage and other html methods.

Although wxHtmlWindow is a desendant of wxScrolledWindow, what's the logic of returning a wxScrolledWindow when I am telling XRC to load wxHtmlWindow? Is this a bug?

No, in order for the OOR code to be able to give you an object of type wxHtmlWindow it has to know about the type. So I'm guessing that you havn't imported the wx.html module and so OOR doesn't know about the type and so looks at the parent class. Since it does know about wxScrolledWindow that is what it gives you. Try adding a "import wx.html" in your code.

Importing wx.html does the trick. Thanks.

Another silly question: how do I get the wxHtmlWindow control to display a paragraph in wrapped form instead one line per paragraph? I set the window style to wx.html.HW_DEFAULT_STYLE, and then have to scroll horizontally to see the complete text.

It should do so automatically. What else is on the page? What tags are used for that block of text?

I found the reason: the text is in Chinese. It seems that wx.HtmlWindow doesn't know how to wrap Chinese texts automatically and displays them as a single line. When the text is English, there is no problem.

What can be done here?

···

--
HONG Yuan
Homemaster Trading Co., Ltd.
No. 601, Bldg. 41, 288 Shuangyang Rd. (N)
Shanghai 200433, P.R.C.
Tel: +86 21 55056553
Fax: +86 21 55067325
E-mail: hongyuan@homemaster.cn

Hong Yuan wrote:

Another silly question: how do I get the wxHtmlWindow control to display a paragraph in wrapped form instead one line per paragraph? I set the window style to wx.html.HW_DEFAULT_STYLE, and then have to scroll horizontally to see the complete text.

It should do so automatically. What else is on the page? What tags are used for that block of text?

I found the reason: the text is in Chinese. It seems that wx.HtmlWindow doesn't know how to wrap Chinese texts automatically and displays them as a single line. When the text is English, there is no problem.

What can be done here?

In trying to go around this, I replaced wx.HtmlWindow with wx.lib.iewin.IEHtmlWindow and write a customer XML handler to load the object from xrc file. The control loads without problem.

However, when I use XRCCTRL to get the object back so that I can use LoadString method of IEHtmlWindow to change the content of the control, it turns out that the control returned by XRCCTRL is of type <wx._core.Window> and thus doens't know about LoadString.

Even when I recreated an IEHtmlWindow with python code and try to use GetChildren of its parent, I get back the object of class <wx._core.Window>:
>>> frame = wx.Frame(None)
>>> ie = iewin.IEHtmlWindow(frame)
>>> frame.GetChildren()
[<wx._core.Window; proxy of C++ wxWindow instance at _f0960e01_p_wxWindow>]\

Is there anything special about IEHtmlWindow?

···

--
HONG Yuan
Homemaster Trading Co., Ltd.
No. 601, Bldg. 41, 288 Shuangyang Rd. (N)
Shanghai 200433, P.R.C.
Tel: +86 21 55056553
Fax: +86 21 55067325
E-mail: hongyuan@homemaster.cn

Hong Yuan wrote:

I found the reason: the text is in Chinese. It seems that wx.HtmlWindow doesn't know how to wrap Chinese texts automatically and displays them as a single line. When the text is English, there is no problem.

What can be done here?

Enter a bug report with a category of "HTML"

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hong Yuan wrote:

Even when I recreated an IEHtmlWindow with python code and try to use GetChildren of its parent, I get back the object of class <wx._core.Window>:
>>> frame = wx.Frame(None)
>>> ie = iewin.IEHtmlWindow(frame)
>>> frame.GetChildren()
[<wx._core.Window; proxy of C++ wxWindow instance at _f0960e01_p_wxWindow>]\

Is there anything special about IEHtmlWindow?

The type ID and OOR info was not added for this class. I'll fix that today.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!