Phoenix wxpTag issue

1 view
Skip to first unread message

Duane Kaufman

unread,
Apr 17, 2013, 3:37:36 PM4/17/13
to wxPyth...@googlegroups.com
Hello,

I am trying to get a simple script running that uses wxpTags under Windows 7. This works with Python 2.7 and wxPython 2.9.3.1, but fails under Python 3.3 and Phoenix 2.9.5.81-r73784
I know this has to do with the change in how the HtmlParser is connected to the HtmlWindow, but I do not know how to fix this.

Can anyone help?

The script:
#!/usr/bin/python

import wx, wx.html
import sys, os
import wx.lib.wxpTag

class HtmlWindow(wx.html.HtmlWindow):
    def __init__(self, parent, id, size=(600,400)):
        wx.html.HtmlWindow.__init__(self,parent, id, size=size)

class Frame(wx.Frame):
    def __init__(self, title):
        wx.Frame.__init__(self, None, title=title, pos=(150,150), size=(600,400))
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        hwin = HtmlWindow(self, -1, size=(600,400))
        name = 'widgetTest.htm'
        hwin.LoadPage(name)

    def OnClose(self, event):
        self.Destroy()

app = wx.App()
top = Frame("wxpTest")
top.Show()
app.MainLoop()

The html file I am using:
<html>

<head>
<title>wxHTML does wxPython!</title>
</head>
<body bgcolor="#00CCFF">
<h2>Mixing wxPython and wxHTML</h2>

The widgets on this page were created dynamically on the fly by a
custom wxTagHandler found in wxPython.lib.wxpTag.  You can look at the
sources and doc-string in the wxPython library at wx/lib/wxpTag.py.

<p>
The button below is added to the page like this:

<pre>
&lt;center>&lt;wxp module="wx" class="Button" width="50%">
    &lt;param name="label" value="It works!">
    &lt;param name="id"    value="ID_OK">
&lt;/wxp>&lt;/center>
</pre>

<hr>

<center>
<wxp module="wx" class="Button" width="50%">
    <param name="label" value="It works!">
    <param name="id"    value="ID_OK">
</wxp>
</center>

</body></html>



The Traceback:
Traceback (most recent call last):
  File "c:\python33\lib\site-packages\wx\lib\wxpTag.py", line 117, in HandleTag
    return self.HandleWxpTag(tag)
  File "c:\python33\lib\site-packages\wx\lib\wxpTag.py", line 165, in HandleWxpT
ag
    parent = self.GetParser().GetWindowInterface().GetHTMLWindow()
AttributeError: 'wxpTagHandler' object has no attribute 'GetParser'


Thanks,
Duane

werner

unread,
Apr 17, 2013, 4:47:00 PM4/17/13
to wxPyth...@googlegroups.com
Hi Duane,

On 17/04/2013 21:37, Duane Kaufman wrote:
...
>
> The Traceback:
> Traceback (most recent call last):
> File "c:\python33\lib\site-packages\wx\lib\wxpTag.py", line 117, in
> HandleTag
> return self.HandleWxpTag(tag)
> File "c:\python33\lib\site-packages\wx\lib\wxpTag.py", line 165, in
> HandleWxpT
> ag
> parent = self.GetParser().GetWindowInterface().GetHTMLWindow()
> AttributeError: 'wxpTagHandler' object has no attribute 'GetParser'
>
wx.lib.wxpTag is not yet ported to Phoenix, unless someone forgot to
mark it as such.

Haven't used this but if I read the source correctly GetParser should
come from HtmlTagHandler and as per the Phoenix doc (for r73820) this
doesn't have a GetParser method.

Werner

Duane Kaufman

unread,
Apr 17, 2013, 5:13:56 PM4/17/13
to wxPyth...@googlegroups.com
Hi,

Thanks for looking into this.
Yes, I read of how the HtmlParser has been moved. From HtmlWinTagHandler:
"This is basically HtmlTagHandler except that it is extended with protected member m_WParser pointing to the HtmlWinParser object (value of this member is identical to HtmlParser’s m_Parser)."

I am a real newbie to this, but I believe if I could access the Parser in my HtmlWinParser, I could modify wxpTag.py on my own to do the right thing.
How does one access a protected member from Python?

Thanks,
Duane
 

werner

unread,
Apr 18, 2013, 1:46:47 AM4/18/13
to wxPyth...@googlegroups.com
Hi Duane,

On 17/04/2013 23:13, Duane Kaufman wrote:
...
Yes, I read of how the HtmlParser has been moved. From HtmlWinTagHandler:
"This is basically HtmlTagHandler except that it is extended with protected member m_WParser pointing to the HtmlWinParser object (value of this member is identical to HtmlParser�s m_Parser)."

I am a real newbie to this, but I believe if I could access the Parser in my HtmlWinParser, I could modify wxpTag.py on my own to do the right thing.
How does one access a protected member from Python?
That is why over my head, so can't help here.

I would guess that Robin will look into this when he finds the time and do the "right thing" for Phoenix - so I would just be patient on this and work on other things.

If you feel up to it you could do the porting work for wxpTag.

You should probably read these:
http://wiki.wxpython.org/ProjectPhoenix/LibraryMigration
http://wxpython.org/Phoenix/docs/html/MigrationGuide.html
http://wxpython.org/Phoenix/docs/html/DocstringsGuidelines.html
http://wxpython.org/Phoenix/docs/html/classic_vs_phoenix.html

My approach to it all is if I use a module in 2.9.5 and I see it is not ported - flags in the code as defined here: http://wiki.wxpython.org/ProjectPhoenix/LibraryMigration, I try and see if I can update/port it.

Repo I use: http://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk

�Werner

Robin Dunn

unread,
Apr 18, 2013, 9:36:38 AM4/18/13
to wxPyth...@googlegroups.com
werner wrote:
> Hi Duane,
>
> On 17/04/2013 23:13, Duane Kaufman wrote:
> ...
>> Yes, I read of how the HtmlParser has been moved. From HtmlWinTagHandler:
>> (http://wxpython.org/Phoenix/docs/html/html.HtmlWinTagHandler.html?highlight=htmlwintaghandler#html.HtmlWinTagHandler)
>> "This is basically HtmlTagHandler except that it is extended with
>> protected member m_WParser pointing to the HtmlWinParser object (value
>> of this member is identical to HtmlParser�s m_Parser)."
>>
>> I am a real newbie to this, but I believe if I could access the Parser
>> in my HtmlWinParser, I could modify wxpTag.py on my own to do the
>> right thing.
>> How does one access a protected member from Python?
> That is why over my head, so can't help here.
>
> I would guess that Robin will look into this when he finds the time and
> do the "right thing" for Phoenix - so I would just be patient on this
> and work on other things.

I started looking in to it last night, but I'm not at home this week so
it is a little slow going for now.

--
Robin Dunn
Software Craftsman
http://wxPython.org

Robin Dunn

unread,
Apr 23, 2013, 9:54:40 PM4/23/13
to wxPyth...@googlegroups.com
Robin Dunn wrote:
> werner wrote:
>> I would guess that Robin will look into this when he finds the time and
>> do the "right thing" for Phoenix - so I would just be patient on this
>> and work on other things.
>
> I started looking in to it last night, but I'm not at home this week so
> it is a little slow going for now.
>

It turned out that there were several problems lurking in this area. I
think I've got them all fixed though, please try again with the next
snapshot build.
Reply all
Reply to author
Forward
0 new messages