Hi, I really need help please!
Im working on WxPython and im trying to subclass a wxHtmlWindow
control with XRC and catch the wxEVT_COMMAND_HTML_LINK_CLICKED event.
Ive found examples for other controls but similar code didn't seem to
work for me if i used a wxHtmlWindow instead.
Here's my code, I have put it in a pastebin for your convenience:
http://pastebin.ca/667746
And heres the page that shows how to do it for another control:
http://wiki.wxpython.org/SubclassingListCtrlWithXrc
What I'm basically trying to do is when the user clicks a link, it
will get the link as a string, then pass it to webbrowser.open()
It can then stop it from proceeding onto the next page the web browser
control (as the fully featured web browser that the user has installed
will load the page)
Am I looking at it in a more complex way than needed? Is this the best
way? What do I need to change in my code to get this working or what
code do I use?
···
--
Thanks, Richie Ward
Cool, Thanks a bunch.. I bet your a pro!
It works now with this code:
class cl(html.HtmlWindow):
def __init__(self):
pre = html.PreHtmlWindow()
self.PostCreate(pre)
dir(self)
def OnLinkClicked(self, linkinfo):
print "thanks!"
···
On 8/23/07, Robin Dunn <robin@alldunn.com> wrote:
Richie Ward wrote:
> Hi, I really need help please!
>
> Im working on WxPython and im trying to subclass a wxHtmlWindow
> control with XRC and catch the wxEVT_COMMAND_HTML_LINK_CLICKED event.
>
> Ive found examples for other controls but similar code didn't seem to
> work for me if i used a wxHtmlWindow instead.
>
> Here's my code, I have put it in a pastebin for your convenience:
> http://pastebin.ca/667746
>
> And heres the page that shows how to do it for another control:
> SubclassingListCtrlWithXrc - wxPyWiki
>
> What I'm basically trying to do is when the user clicks a link, it
> will get the link as a string, then pass it to webbrowser.open()
> It can then stop it from proceeding onto the next page the web browser
> control (as the fully featured web browser that the user has installed
> will load the page)
>
> Am I looking at it in a more complex way than needed? Is this the best
> way? What do I need to change in my code to get this working or what
> code do I use?
>
class cl(wx.html.HtmlWindow):
def __init__(self):
pre = wx.PreCheckBox()
self.PostCreate(pre)
self.Bind(wx.html.wxEVT_COMMAND_HTML_LINK_CLICKED,
self.OnLinkClicked)
Your problem is in the 3rd line. You are creating an uninitialized
instance of a wx.CheckBox, but in the 4th line you are trying to do the
post initialization of a HtmlWindow using that instance, which is
resulting in the TypeError. Try using this instead:
pre = wx.html.PreHtmlWindow()
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
--
Thanks, Richie Ward