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

F

furby

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.
 
M

Mike Driscoll

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.
 
F

furby

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):
It sounds eminently reasonable. I'll try it tonight when I get home
and let you know if it works!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top