I want to write an application which shows the lyrics of a French song in one window and, when the user clicks on a line in that window, the English translation of that line appears in another window. I thought it should be possible to do this using an HtmlWindow with a custom tag to store the translation for a line, like the following. (Here is a custom tag with parameter “trans”.)
page = “”"
J’ai dansé avec l’amour
J’ai fait des tours et des tours
"""
The lyrics window will then show:
J’ai dansé avec l’amour
J’ai fait des tours et des tours
Clicking on a line should then show the associated translation. But for that I need to get the value of the attribute “trans” for the line clicked on. I know how to get the line (container cell) clicked on but I don’t know how to get the value of its attribute “trans”. Can someone help?
It's likely that you can't do that -- wx.HTMLWindow supports a pretty limited subset of HTML. (if I'm wrong, I hope someone will speak up)
I'd keep the translation<->original text mapping in your own data structure in Python, instead of within the HTML.
-CHB
···
On 9/7/11 1:38 PM, Patrick wrote:
I want to write an application which shows the lyrics of a French song
in one window and, when the user clicks on a line in that window, the
English translation of that line appears in another window. I thought it
should be possible to do this using an HtmlWindow with a custom tag to
store the translation for a line, like the following. (Here <line> is a
custom tag with parameter "trans".)
page = """<html><body>
<line trans="I danced with love">
J'ai dans� avec l'amour<br>
</line>
<line trans="I went round and round">
J'ai fait des tours et des tours
</line>
</body></html>"""
The lyrics window will then show:
J'ai dans� avec l'amour
J'ai fait des tours et des tours
Clicking on a line should then show the associated translation. But for
that I need to get the value of the attribute "trans" for the line
clicked on. I know how to get the line (container cell) clicked on but I
don't know how to get the value of its attribute "trans". Can someone help?
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov