473,324 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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

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.
Jul 6 '08 #1
2 945
On Jul 6, 8:18*am, furby <Wookie...@gmail.comwrote:
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
Jul 7 '08 #2
On Jul 7, 10:34*am, Mike Driscoll <kyoso...@gmail.comwrote:
On Jul 6, 8:18*am, furby <Wookie...@gmail.comwrote:
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):
It sounds eminently reasonable. I'll try it tonight when I get home
and let you know if it works!
* * 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
Jul 7 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: A | last post by:
Hi, I have a program that downloads some web pages. Sometimes there is a poor internet connection and my script freezes( hangs) and does not download ALL pages. Is there any solution how to test...
6
by: Henro V | last post by:
And if there is one, is there a way to make forms that are wider? For every day on the form (first field) it needs to be followed by 52(!) datefields. I've widened the form as far as I can but I...
37
by: Greg | last post by:
Except for legacy or non-.NET applications, is there any reason to use VC++ anymore? It seems that for .NET applications, there would be no reason to choose C++ over C# since C# is faster to...
11
by: jjbutera | last post by:
I know how to use the ErrorProvider in my winforms..or do I? I validate the values and set the ErrorProvider in the validating event. If not valid, I set e.Cancel = True. I clear the ErrorProvider...
12
by: Jan | last post by:
Hi: I've got the Error 3197 problem ("The Microsoft Jet database engine stopped the process because you and another user are attempting to change the same data at the same time.") in a client...
13
by: andrewanderson | last post by:
hi all, i'm wondering is there any other alternative to do a timestamp which consists of date and time!! below is a program i've created but its too long and to large i would like to know other...
1
by: bb | last post by:
Hi, Is there any specific reason(s) that there is only one namespace 'std' in the standard library? e.g. namespaces are not really independent, name collisions etc. Should one consider not...
10
by: mark4asp | last post by:
I ask this because only today I read advice telling me to put it within the <headelement. This is the same advice I've always been given but no one ever explained why. Last week I was told to...
3
by: Peter Oliphant | last post by:
It's not necessary, but it would be nice if there was a way I could easily create something like a 'web browser form' or a 'display web page form' as forms in my application (in a Panel would be...
1
by: Earl Anderson | last post by:
I have a form with many fields, each of which has their separate record sources in a split db. Today, several users throughout the afternoon encountered the following message when accessing...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.