[pygtk] quoting text for markup
Darren Hart
darren at dvhart.com
Fri Mar 20 00:28:52 WST 2009
On Thu, Mar 19, 2009 at 12:59 AM, Walter Leibbrandt
<walter at translate.org.za> wrote:
> Hi
>
> Darren Hart wrote:
>>
>> When adding text with an & character to a cellrenderertext I get some
>> rendering glitches (and the actual text doesn't get rendered at all).
>> Is there a standard mechanism for quoting text destined for the markup
>> property?
>
> Since Pango markup strings are XML strings, you should also quote your
> markup strings as such. That means that an & should become &.
RIght & < and > - but my question was if there is some python call to
do this or if I just have to roll my own. I recently added this to my
code base:
def quote_markup(str):
return str.replace("&", "&").replace(">", ">").replace("<", "<")
It just would be nice if gtk offered something like that - or at least
didn't break if you put an & in the text. My version is pretty
braindead, but if I use it carefully in my app, it works fine.
Thanks,
> --
> Walter Leibbrandt Software Developer
> Recent blogs:
> * Firefox-style button with a pop-up menu
> http://www.translate.org.za/blogs/walter/en/content/firefox-style-button-pop-menu
Heh, I recently wrote one of those as well - with some examples from a
google code project.
--
Darren Hart
More information about the pygtk
mailing list