Hi there! I need what is probably a very basic lesson in events....

Mike Driscoll kyosohma at gmail.com
Mon Jul 7 10:34:56 EDT 2008


On Jul 6, 8:18 am, furby <Wookie... at gmail.com> wrote:
> I am teaching myself Python... I'm nowhere near even intermediate
> level yet, so treat me like an idiot. I am using Boa Constructor on
> Ubuntu 8.04 if that helps. Here is what I have right now :
>
> I am plying with reading a URL (An RSS feed to be exact) and
> displaying it inside a HTMLWindow. I have that part working - It shows
> the title as a link and displays the description next to it. What I
> want to do is trap the mouseclick on the link and use that to grab
> just the text that is on the site. Right now, if I click on it, the
> HTML window control takes me to the site and doesn't really show the
> site very well, since it doesn't seem to do CSS. That's okay - I just
> want to display the text.... How do I trap the mouse clicking on the
> link?
>
> I know that HTMLwindow has a "OnLinkClicked" event - I can see it in
> the docs for that control. But it seems that Boa Constructor doesn't
> expose that event in it's frame designer.... How do I code a event
> that fires off instead of the default event?
>
> I don't know if I am being clear enough, so if not just tell me what I
> should say... Liek I said, I am a newbie right now.


I think you just need to override that method (OnLinkClicked) in the
class you use to subclass the HtmlWindow widget. Something like this:

<code>
class MyCustomDlg(wx.Frame):

    def __init__(self, parent, title, icon, pos):

        wx.Frame.__init__(self, parent, wx.ID_ANY, title,
size=(400,400))

        x,y = pos
        self.SetPosition((x+30, y+30))

        self.SetIcon(icon)
        html = wxHTML(self)


class wxHTML(wx.html.HtmlWindow):
     def OnLinkClicked(self, link):
         # do something here
         pass
</code>

However, for wxPython questions, it's best to post to the wxPython
user's group. They are very knowledgeable there. http://wxpython.org/maillist.php

Hope that helps.

-------------------
Mike Driscoll

Blog:   http://blog.pythonlibrary.org
Python Extension Building Network:     http://www.pythonlibrary.org



More information about the Python-list mailing list